How do I set a variable on when touching an object?

Get help using Construct 2

Post » Thu Oct 22, 2015 10:36 am

My idea is that when the player is touching a wall, they'll be able to perform a wall jump. To implement this, I'm using a global variable which, when set at >0, will allow the player to wall jump. The problem I'm having is I can't find a way of dynamically changing the variable based on whether the two objects are colliding. If I set the player to 'on collision with wall' then the variable is stuck at value 1, since I can't find a way to change it back to 0 using another condition, nor can I use an 'else' statement. I tried 'is overlapping with' but that didn't seem to do anything. Anyone got ideas on how I can do this?
All help appreciated!
B
5
Posts: 26
Reputation: 285

Post » Thu Oct 22, 2015 12:32 pm

You can use 'is overlapping with offset'. This enables you to use an else.

When the wall is to the right the offset should be -1, and to the left 1.
Banned User
B
6
S
3
Posts: 105
Reputation: 1,170

Post » Thu Oct 22, 2015 12:35 pm

To go back to value 0 you can inverse a condition by hitting i on your keyboard
Choose the condition "Is overlapping" wall then hit i.
The action would be set global variable to 0
It's time for me to return the favor :)
B
32
S
9
G
9
Posts: 132
Reputation: 5,370

Post » Mon Nov 02, 2015 3:00 pm

tarik00555 wrote:You can use 'is overlapping with offset'. This enables you to use an else.

When the wall is to the right the offset should be -1, and to the left 1.

This works perfectly and was exactly what I was looking for! Thanks a lot man!
B
5
Posts: 26
Reputation: 285

Post » Wed Nov 04, 2015 11:48 pm

Ok, all solved.
B
30
S
9
G
3
Posts: 280
Reputation: 4,212


Return to How do I....?

Who is online

Users browsing this forum: Unconnected and 23 guests