playMaker

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

aaronpaulina

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
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, 03:05:46 PM by Alex Chouls »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14035
  • Official Playmaker Support
    • View Profile
Re: Interpolate between two points RELATIVE to where it's positioned
« Reply #1 on: March 29, 2012, 01: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
    • View Profile
Re: Interpolate between two points RELATIVE to where it's positioned
« Reply #2 on: March 29, 2012, 04: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: 14035
  • Official Playmaker Support
    • View Profile
Re: Interpolate between two points RELATIVE to where it's positioned
« Reply #3 on: March 29, 2012, 04: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
    • View Profile
Re: Interpolate between two points RELATIVE to where it's positioned
« Reply #4 on: March 29, 2012, 10:10:07 AM »
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
  • Full Member
  • *
  • Posts: 228
    • View Profile
Re: Interpolate between two points RELATIVE to where it's positioned
« Reply #5 on: March 29, 2012, 11:51:47 AM »
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: 14035
  • Official Playmaker Support
    • View Profile
Re: Interpolate between two points RELATIVE to where it's positioned
« Reply #6 on: March 30, 2012, 12:44:38 AM »
I am glad you cracked it!

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

 Bye,

 Jean