playMaker

Author Topic: Interpolate between two points RELATIVE to where it's positioned [SOLVED]  (Read 3625 times)

aaronpaulina

  • Playmaker Newbie
  • *
  • Posts: 3
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.
« Last Edit: March 30, 2012, 06:05:46 PM by Alex Chouls »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Interpolate between two points RELATIVE to where it's positioned
« Reply #1 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

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

Then you should be up with this.

 Bye,

 Jean

aaronpaulina

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Interpolate between two points RELATIVE to where it's positioned
« Reply #2 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?  :(

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Interpolate between two points RELATIVE to where it's positioned
« Reply #3 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

aaronpaulina

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Interpolate between two points RELATIVE to where it's positioned
« Reply #4 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.

 

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: Interpolate between two points RELATIVE to where it's positioned
« Reply #5 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.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Interpolate between two points RELATIVE to where it's positioned
« Reply #6 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