How do I change the enemy direction with variables?

Get help using Construct 2

Post » Mon Dec 07, 2015 12:15 am

I can't work out why the enemy is okay with changing direction with it's moving to the right but not to the left?
https://www.dropbox.com/s/c85flbvdukw5w ... .capx?dl=0
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,248

Post » Mon Dec 07, 2015 5:41 am

The problem is, when you collide, the events change so quickly that it triggers both events. In your example, on collision, with variable=0, set it to 1. But it is still on collision and now the variable=1, so it triggers the other event and set's it back to 0. The easiest way to solve this, is add a wait event just before you set the variable to its new value. Add a wait 0.1 second and it will solve your issue and it won't be noticeable by players as well.
B
41
S
20
G
31
Posts: 684
Reputation: 20,189

Post » Mon Dec 07, 2015 6:31 am

Wow, thank you, that works perfectly! 0.01 seconds worked :D
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,248

Post » Mon Dec 07, 2015 10:08 am

Using "Else" would actually be a much better option..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Dec 07, 2015 11:39 am

LittleStain wrote:Using "Else" would actually be a much better option..


Yup, agree with LittleStain on this. It would be a better common practice to use else in this situation.
B
41
S
20
G
31
Posts: 684
Reputation: 20,189


Return to How do I....?

Who is online

Users browsing this forum: plinkie, rtkiii and 11 guests