Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Rungo73

Hi

I have two entities - player and ladder.

I'm using check() to determine if player has touched the ladder.

Inside I'm setting a Boolean (onLadder) to true.

I can't seem to get it to set to false when the player moves away
from ladder.

I tried an if/else inside the check function but to no avail?

Any suggestions, most appreciated.

1 decade ago by Krisjet

The check() only runs when they are touching, so it will never set it to false that way.

1 decade ago by kaboo

why do you need onLadder variable? the player is on ladder whenever the check function fires.

1 decade ago by Rocket13531

Hi Rungo, I've written a ladder class that is working very well for me and came across the same dilemma. Here is what I did:

at the end of my update class (after calling parent()) I set onLadder to false.

//this.onLadder = false;

Then, in check, which executes before the update function runs again, I basically reset this.onLadder to true after running some conditionals.

If check() didn't execute, this.onLadder would remain false.

1 decade ago by Rungo73

Thank you for the responses.

I've ended up using .touches() and it works a charm.

Always pays to dig through the API.

Cheers
Page 1 of 1
« first « previous next › last »