Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: LuminRabbit on October 30, 2018, 10:48:33 PM

Title: Change Direction / Math Operator Question
Post by: LuminRabbit on October 30, 2018, 10:48:33 PM
I have an NPC moving in the X direction with a speed variable set to 1. When it collides with an object I need its speed variable to be -1 so that it moves in the other direction.

I can hard code this with another variable and have it set to -1 with something like Set Float Value but if I have different enemies set at different speeds (5 to -5) that will also collide with this object it wouldn't work.

How would I do the math / use actions and variables to make this happen?
Title: Re: Change Direction / Math Operator Question
Post by: Athin on October 31, 2018, 03:54:54 AM
Just simply have the speed variable get multiplied by -1 when it trips the trigger.  So as long as you need it to go the exact speed in the opposite direction, it will work. 
Title: Re: Change Direction / Math Operator Question
Post by: LuminRabbit on October 31, 2018, 09:28:33 AM
Doh... Now that you told me it makes perfect sense :D Anything multiplied by 1 is anything (weather negative or positive).
Thank you so very much!