Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started 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
-
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.
-
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 ;)
-
@krmko..thanks for feedback
@Plancksize Thanks:) ill try that.
-
@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.
-
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
-
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)
-
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:)