How to change variable after collision?

R

Riverlox

Guest
I instantiate my variable and then later I have a collision that I want to make the jumpheight smaller. I have this but it does not work. I changed the number from -10 to -20 and it did change the jumpheight but the collision does not. I need assistance.
jumpheight = -10


if (place_meeting(x+hsp, y, EggBurrito_object))
{
jumpheight += 5;
}
 

Tyg

Member
Whats hsp? is it Variable? beacause the place_meeting will not be at the objects position
 
R

Riverlox

Guest
Whats hsp? is it Variable? beacause the place_meeting will not be at the objects position
Yeah, sorry, I had it in the jumpheight in Step when I instantiated so it was in the wrong place it had to go in create.
 
  • Like
Reactions: Tyg

hogwater

Member
If the burrito is an item you collect, you want to check for a collision like this:

Code:
if (place_meeting(x, y, EggBurrito_object))
{
jumpheight += 5;
}
Remember to destroy the burrito object as well, or you'll just keep adding +5 to the jump height every frame while you are colliding.
 

kburkhart84

Firehammer Games
You should also make sure that you are setting jumpHeight only once in the create event, and not changing it in the step event. Even if you change it in the collision event or during that place_meeting() code, if you put it in the step event it will change it back every single frame.
 
Top