Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: jameshark on April 18, 2018, 01:45:49 AM

Title: Get Position of another object (using self) [SOLVED]
Post by: jameshark 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.
Title: Re: Get Position of another object (using self)
Post by: jeanfabre 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
Title: Re: Get Position of another object (using self)
Post by: jameshark 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.
Title: Re: Get Position of another object (using self)
Post by: jameshark 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.