Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: hoyoyo80 on July 27, 2018, 02:42:16 AM

Title: get position between two targets
Post by: hoyoyo80 on July 27, 2018, 02:42:16 AM
Hi playmakers,

I need someone help. Let say i  have a two targets in 3D,start and finish, how can i get a position at 1/4,1/2,3/4 of the distance of these two targets?

Thanks
Title: Re: get position between two targets
Post by: Fat Pug Studio on July 27, 2018, 04:33:19 AM
How fast does it need to be? I've got an ad hoc solution until someone smarter reads thism get distance between objects, spawn third object, move it half the distance and get position for 1/2 distance position etc.

Needless to say, this is not a solution for every frame or when you need it quickly.

I'm afk now, but i presume proper solution involves vector length.
Title: Re: get position between two targets
Post by: Plancksize on July 27, 2018, 07:16:45 AM
You can do that with simple vector math:

Vector A + Vector B = Vector AB
Vector AB / 2 = Vector C

Being vector C the middle point between A and B.

PS: Don't forget to use local position if you're working with a local space.


PS2: I've been forcing myself to look into code and try out / learn new things, so I took this as a "exercise" and created this noobish (yet seems to be working) action to find a mid point between two objects (vector3).
Attached it to the post and it does seem to be working here.

Hope it helps ;)
Title: Re: get position between two targets
Post by: hoyoyo80 on July 28, 2018, 09:47:58 AM
@krmko..thanks for feedback

@Plancksize Thanks:) ill try that.
Title: Re: get position between two targets
Post by: Plancksize on July 28, 2018, 09:56:27 AM
@krmko..thanks for feedback

@Plancksize Thanks:) ill try that.

Cheers.
Poke if it worked for you. I also added a Vector2 version of it on the "share actions" forum.
Title: Re: get position between two targets
Post by: hoyoyo80 on July 30, 2018, 11:22:54 PM
Hi...im able to get correct midpoint between two objects by vector in playmaker using ur formula...but doing it by 1/4 and 3/4 return weird result. Thanks
Title: Re: get position between two targets
Post by: Plancksize on July 31, 2018, 07:30:09 AM
Here's an image ( MSPaint skills..sorry ) showing the way I'd do it to get the 1/4 and 3/4 way (because sometimes 1 image is worth 1000 words)
Title: Re: get position between two targets
Post by: hoyoyo80 on August 04, 2018, 08:46:50 PM
Thanks for the feedback:) ive found it already. if mid point is (v1+v2)/2, the other vector depend on fraction,e.g v1*1/4+v2*3/4, for 1/4 and 3/4 point.

Thanks:)