playMaker

Author Topic: Get Position of another object (using self) [SOLVED]  (Read 1626 times)

jameshark

  • Playmaker Newbie
  • *
  • Posts: 12
Get Position of another object (using self) [SOLVED]
« on: April 18, 2018, 01:45:49 AM »
Hi,

I've come across an issue where if I use the Get Position action in an object to get the position of another object, using the space Self instead of World. It will still get the position of the target object in relation to the center of the scene instead of the position of the main object (which has a x position of 10, away from the centre).

this is causing some projectiles thrown by the player to act as if the target is in relation to the center.

Is there a reason why this might be happening or am I doing it wrong.
« Last Edit: April 18, 2018, 05:50:14 AM by jameshark »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get Position of another object (using self)
« Reply #1 on: April 18, 2018, 02:39:10 AM »
Hi,

 yeah, GetPosition is working like that, it's Unity thing.

 If you want the position relative to another object, you either need that object to be the child of it, then it's position will be relative to its parent, or substract the world position of the object with the world position of the reference ( what would be the parent)

 Bye,

 Jean

jameshark

  • Playmaker Newbie
  • *
  • Posts: 12
Re: Get Position of another object (using self)
« Reply #2 on: April 18, 2018, 02:59:14 AM »
thanks for explaining that to me, haven't found an exact solution to it yet but at least I have a better idea now.

jameshark

  • Playmaker Newbie
  • *
  • Posts: 12
Re: Get Position of another object (using self)
« Reply #3 on: April 18, 2018, 05:49:45 AM »
Your last method seemed to be the one that worked!

I took the x and y of the main object and placed it into a vector 2. Then used vector subtract with both the target's vector and the main objects vector, now everything seems to be working okay!

Thanks again for the help.