0

I want the alpha (of the sparks) to be reset every time the character gets off the wall (stops wallsliding) so the alpha only reaches 0 if the player is wallsliding for a really long time.

Variables

Remaining Code

I can't fix that you can reach alpha value of 0 if you wallslide multiple times (jump of the wall and jump on it again) because the value is not being reset to 1 (no transparency).

Please help.

Lesiak
  • 3
  • 3
  • 1
    Hy, welcome to Stack Overflow, please [don't upload text, table or error message as image](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors/285557#285557). Edit your question to contain all the information in text form - consider to use the editor's formatting options. Also see [How to Ask](https://stackoverflow.com/help/how-to-ask) – Daxelarne Apr 11 '23 at 13:41

1 Answers1

0

you are resetting the alpha of Particles to 1 when you detect you are wallsliding, but this won't work because you overwrite it in this case anyway with your alpha variable, which you don't reset.

What you should do, is reset the variable alpha to 1 any time you detect, that the character is not wallriding. As your code is structured you don't need to reset the alpha of your particles to 1, because you overwrite it with your alpha variable anyway.

Without testing it, I think it should look like this:

if is_on_wall() and not is_on_floor():
    if input.is_action_pressed("ui_right") or Input.is_action_pressed("ui_left"):
        is_wall_sliding = true
    else:
        is_wall_sliding = false
else:
    is_wall_sliding = false

if is_wall_sliding == true:
    velocity.y = wall_slide_gravity
    sparks_fade()
else:
    alpha = 1 
Bugfish
  • 725
  • 5
  • 14
  • One day after posting this question here I somehow made it work by myself so I continued writing the code with it, but when I tested your solution it also worked! Thanks! – Lesiak Apr 15 '23 at 17:15