Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: HeathClose on January 11, 2017, 04:45:47 PM

Title: Negate a vector coordinate [SOLVED]
Post by: HeathClose on January 11, 2017, 04:45:47 PM
I have an fsm spawning a game object at random points...

it stores that location.. for example... -1.4, 133, 0

this is a 2d game, so i want that object to now tween along the x axis... for example...

ping pong from -1.4, 133, 0 (where it spawned) and 1.4, 133, 0

is there a way to use an action to get the location to tween to as a negative of the x coordinate?

I tried using this...

(https://www.dropbox.com/s/n8fud72028t34jh/Screenshot%202017-01-11%2015.37.40.png?dl=1)

but that just breaks the syntax and makes it all 0,0,0... (pic not of runtime... i know there isn't a string to change it to in the pic but I get a variable at runtime)

How could I do this?
Title: Re: Negate a vector coordinate
Post by: jrock84 on January 11, 2017, 09:00:31 PM
If I'm not mistaken, you can just multiply your variable with vector multiply and that should get it.
Title: Re: Negate a vector coordinate
Post by: HeathClose on January 11, 2017, 09:58:07 PM
If I'm not mistaken, you can just multiply your variable with vector multiply and that should get it.

Awesome... i didn't know that was a thing... thank you...

when I multiply the vector 3 by -1... it multiplies them all by -1, so instead of tweening along the x axis and it's negative... it also tweens to the y axis negative... and I only want to multiply the x by -1...
Title: Re: Negate a vector coordinate
Post by: jrock84 on January 11, 2017, 10:56:25 PM
Which itween action are you using for your movement?
Title: Re: Negate a vector coordinate
Post by: HeathClose on January 12, 2017, 11:34:28 AM
Which itween action are you using for your movement?

itween move to set to ping pong
Title: Re: Negate a vector coordinate
Post by: jrock84 on January 12, 2017, 12:10:15 PM
Take a look at Set Vector3 XYZ. You can 0 out your other two values and leave your X axis unchanged.
Title: Re: Negate a vector coordinate
Post by: HeathClose on January 12, 2017, 05:48:16 PM
Take a look at Set Vector3 XYZ. You can 0 out your other two values and leave your X axis unchanged.

thanks for that idea!

I need to retain my y axis, that one won't work for me
Title: Re: Negate a vector coordinate
Post by: jrock84 on January 12, 2017, 10:04:28 PM
It's configurable. You can alter any of the vectors and keep whatever you want, unless I'm misunderstanding you.
Title: Re: Negate a vector coordinate
Post by: HeathClose on January 14, 2017, 03:25:17 PM
It's configurable. You can alter any of the vectors and keep whatever you want, unless I'm misunderstanding you.

OK!  thank you ... so your help lead me to the solution indeed...

first.. get vector3 xyz and store those values

second... float multiply (the x by -1)

third... set vector3 xyz

Bob's your uncle...

thank you!
Title: Re: Negate a vector coordinate [SOLVED]
Post by: jrock84 on January 14, 2017, 03:27:22 PM
Happy to help!