how can i Change actor's speed every 10 seconds
diegocs
Member Posts: 531
i want my actor to increase speed (for example x+25) every 10 seconds, also take in fact that my actor bounces against the borders of the scene, can someone tell me how to do this
Comments
Next it depends on how you are moving your actor.
If you are not using the Move behavior or the Move To behavior you can do this.
Inside the Timer behavior, use
Change Attribute: self.Motion.Linear Velocity.X to
self.Motion.Linear Velocity.X +25*cos(vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y ))
and
Change Attribute: self.Motion.Linear Velocity.Y to
self.Motion.Linear Velocity.Y +25*sin(vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y ))
Remember to select the attributes from the attribute browser instead of just typing the above in.
Why this works:
the vectorToAngle parts of the expressions give you the angle of the current velocity.
The sin/cos around that angle will give you the number to multiply your increasing value(25) to add to the current Linear X and Y values so that the speed is increased by 25 in the same direction as it is currently going in.
You stole one of the more math heavy examples CodeMonkey!!
Change Velocity behavior: Speed = speed +25
I don't see the need for the math here...
Have been trying to help since before the commotion :P
Angle would be: vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y )
Speed would be: magnitude( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y )+25
Relative to Scene