else if statement

Non-platform specific questions.

else if statement

Postby mal99 » Mon Jul 18, 2011 4:17 pm

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?
mal99
 
Posts: 10
Joined: Tue May 31, 2011 11:47 pm
Score: 0 Give a positive score

Re: else if statement

Postby SuperSonic » Mon Jul 18, 2011 11:40 pm

Try using "+=" instead of "=+" Image
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: else if statement

Postby lcl » Tue Jul 19, 2011 7:27 am

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?
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: else if statement

Postby mal99 » Tue Jul 19, 2011 11:24 am

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.
mal99
 
Posts: 10
Joined: Tue May 31, 2011 11:47 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest