Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: _adamturnbull on March 24, 2014, 04:45:43 PM

Title: Rigidbody 2D face direction it is travelling.
Post by: _adamturnbull on March 24, 2014, 04:45:43 PM
Hi,

Currently I set the velocity of my character at the beginning of the level and then let physics do the rest as it rolls down ramps and whatnot. Is there a way to make sure it always faces the direction it is travelling.

It is a 2D game so only needs to look left or right.

Thanks!
Adam
Title: Re: Rigidbody 2D face direction it is travelling.
Post by: sebaslive on March 24, 2014, 08:16:51 PM
Here is one of the ways, you can getvelocity and if it is positive you use a float compare to tell if less than 0 left event, more than 0 right event. The event that it sends it to can be set to flip it in the direction that you want.
Title: Re: Rigidbody 2D face direction it is travelling.
Post by: _adamturnbull on March 25, 2014, 11:19:14 AM
Thanks, I'll try that. Are there any other ways or is this the best?

Is there a way to only send an event once if it goes below or above 0? Because won't it constantly keep sending the 'positive' or 'negative' events every frame.
Title: Re: Rigidbody 2D face direction it is travelling.
Post by: sebaslive on March 25, 2014, 02:03:56 PM
I am sure there are other ways which hopefully someone else on the forums can help out with but for the below or above 0 you set two states that link to each other. If its below send to left state if it is above you make the left state send to right.