playMaker

Author Topic: Change Direction / Math Operator Question  (Read 1202 times)

LuminRabbit

  • Full Member
  • ***
  • Posts: 161
  • Lumin Rabbit
Change Direction / Math Operator Question
« 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?
Have I said how much I love playmaker!!! This is one amazing tool

Athin

  • Full Member
  • ***
  • Posts: 163
Re: Change Direction / Math Operator Question
« Reply #1 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. 

LuminRabbit

  • Full Member
  • ***
  • Posts: 161
  • Lumin Rabbit
Re: Change Direction / Math Operator Question
« Reply #2 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!
« Last Edit: October 31, 2018, 04:26:35 PM by Kodagames »
Have I said how much I love playmaker!!! This is one amazing tool