Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: aaronpaulina on March 28, 2012, 06:12:09 AM

Title: Interpolate between two points RELATIVE to where it's positioned [SOLVED]
Post by: aaronpaulina on March 28, 2012, 06:12:09 AM
Say I want to have an enemy prefab patrol back and forth, I set its position in the inspector and I want its target position to be Vector3(-4,0,0) relative to its original position. so no matter where I drag the prefab it should always patrol to the left 4 units, then return to it's position.
Title: Re: Interpolate between two points RELATIVE to where it's positioned
Post by: jeanfabre on March 29, 2012, 04:05:59 AM
Hi,

 You should use iTween for this. Specifically the move to action:
https://hutonggames.fogbugz.com/default.asp?W601 (https://hutonggames.fogbugz.com/default.asp?W601)

-- set the "vector position" to -4,0,0
-- set the "space" property to "self"

Then you should be up with this.

 Bye,

 Jean
Title: Re: Interpolate between two points RELATIVE to where it's positioned
Post by: aaronpaulina on March 29, 2012, 07:26:26 AM
I set the vector to -4,0,0 and checked "Self" but it still moves to World position. Is it bugged?  :(
Title: Re: Interpolate between two points RELATIVE to where it's positioned
Post by: jeanfabre on March 29, 2012, 07:48:27 AM
hi,

 Give me a bit of time, I'll crack a working example for tomorow :)

 Bye,

 Jean
Title: Re: Interpolate between two points RELATIVE to where it's positioned
Post by: aaronpaulina on March 29, 2012, 01:10:07 PM
Okay I fixed it so far. :P

For your first state add an iTween Move to Action
Change the transform position to your object's transform
Vector position to how far you want to move and on what axis
Change space to self

Second state is the same thing but your vector position is the negative of your first.

 
Title: Re: Interpolate between two points RELATIVE to where it's positioned
Post by: justifun on March 29, 2012, 02:51:47 PM
Or you can also set the loop type to "ping pong" to make your object travel back to its original starting position as well.
Title: Re: Interpolate between two points RELATIVE to where it's positioned
Post by: jeanfabre on March 30, 2012, 03:44:38 AM
I am glad you cracked it!

Justifin is right, do that with a ping pong  loop type from iTween

 Bye,

 Jean