playMaker

Author Topic: get position between two targets  (Read 2203 times)

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
get position between two targets
« 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

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: get position between two targets
« Reply #1 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.
Available for Playmaker work

Plancksize

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 75
Re: get position between two targets
« Reply #2 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 ;)
« Last Edit: July 27, 2018, 08:29:36 AM by Plancksize »

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Re: get position between two targets
« Reply #3 on: July 28, 2018, 09:47:58 AM »
@krmko..thanks for feedback

@Plancksize Thanks:) ill try that.

Plancksize

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 75
Re: get position between two targets
« Reply #4 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.

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Re: get position between two targets
« Reply #5 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

Plancksize

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 75
Re: get position between two targets
« Reply #6 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)

hoyoyo80

  • Full Member
  • ***
  • Posts: 136
Re: get position between two targets
« Reply #7 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:)