Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Mupp on February 24, 2021, 07:06:58 PM

Title: How to get a center objects relative position
Post by: Mupp on February 24, 2021, 07:06:58 PM
How can I get an objects relative position if it's the middle object of 3 objects in a line? I want this value as a float so I can use it as the amount in a LERP action.
Title: Re: How to get a center objects relative position
Post by: curb47 on February 25, 2021, 03:03:00 AM
Relative to what, World space?

And position is either Vector2 or Vector3 / X, Y, Z , which variable is the float going to affect?
Title: Re: How to get a center objects relative position
Post by: Mupp on February 25, 2021, 09:16:05 AM
Um, what's unclear exactly? Have you never used a LERP action? You have 2 points and you move a 3rd between then using a float as its relative position between them.
Title: Re: How to get a center objects relative position
Post by: wetcircuit on February 25, 2021, 11:11:12 AM
break it down into steps (I see 3 steps)

1. get the difference (actual distance) between start A and end B objects
*probably difference=Abs(B-A)

2. get the difference between the middle object Mid from the start A
*probably midDifference=Abs(Mid-A)

3. divide the 2nd result by the 1st
*probably T=midDifference/difference

T gives you the value to set the Lerp.
Title: Re: How to get a center objects relative position
Post by: Mupp on February 25, 2021, 11:42:09 AM
I don't know what you mean by "probably", but thanks. I'll give this a try.