Page 1 of 1

else if statement

PostPosted: Mon Jul 18, 2011 4:17 pm
by mal99
I want to slow down a filled region actor, which is parent to many clones, when its y-coordinate is greater that -100

I believe the y-coordinate of a filled region is taken as its top left corner.

Why doesn't the following script work?


if (y>-295 && y<-100){yvelocity=+0.17;}
else if (y>-100){yvelocity=+0.05;}


The script is triggered by activation events sent from the child clones when they collide with other actors


Anyone see the error?

Re: else if statement

PostPosted: Mon Jul 18, 2011 11:40 pm
by SuperSonic
Try using "+=" instead of "=+" Image

Re: else if statement

PostPosted: Tue Jul 19, 2011 7:27 am
by lcl
SuperSonic wrote:Try using "+=" instead of "=+" Image

That would cause continuous accelerating. He's using yvelocity, not y. :)

@mal99: you can leave those "+" signs away, numbers are positive even without them. :wink:
Where is that code in?

Re: else if statement

PostPosted: Tue Jul 19, 2011 11:24 am
by mal99
Hi IcI

I just figured this out. Nothing wrong with the script - the problem is in using activation events received from clones as they are destroyed in collisions.

The first activation from Clone zero is received OK when the y coordinate is less than -100. After that, activations received from clones when y is greater than -100 are not recognized. As a result, the script doesn't run again and the actor's speed stays the same as before.

Using "receive activation event from any actor" solves the problem.

Thanks anyway.