# Actor Movement Based On Other Actors

**URL:** <https://forums.unrealengine.com/t/actor-movement-based-on-other-actors/49814>\
**Category:** Character & Animation\
**Tags:** unreal-engine\
**Created:** [December 12, 2015, 11:27am UTC](https://forums.unrealengine.com/t/actor-movement-based-on-other-actors/49814 "2015-12-12T11:27:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![E-Spec](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@E-Spec](https://forums.unrealengine.com/u/E-Spec)\
**Post date:** [December 12, 2015, 11:27am UTC](https://forums.unrealengine.com/t/actor-movement-based-on-other-actors/49814/1 "2015-12-12T11:27:38Z")

</div>

Hi!

I’m developing a little demo wherein I place two spheres and a cylinder. I’m trying to make the cylinder act as a sort of bridge, or connection between the two spheres. I have added a little Blueprint that makes the spheres move up and down independently of each other. The part I am struggling with is that the cylinder should then follow both spheres, and be placed in between them both. The angle of the cylinder should be so that it is pointing from one sphere to the other no matter which sphere is moving. I have added a little sketch of how the movement would look.

 ![RotEx.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/5/c/5c648ff878ffca8e949a989173dcfa60ae5c3386.png)

I would like for this to be axis independent, so that it doesn’t matter if the movement is on the X, Y or Z axis, or a combination of them.

All tips and solutions are much appreciated.

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![ryan20fun](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ryan20fun/32/1194363_2.png) [@ryan20fun](https://forums.unrealengine.com/u/ryan20fun)\
**Post date:** [December 12, 2015, 12:34pm UTC](https://forums.unrealengine.com/t/actor-movement-based-on-other-actors/49814/2 "2015-12-12T12:34:17Z")

</div>

Subtract the two sphere’s world location -\> Normalize.  
Use there world locations to get the distance between them.  
Divide the distance by two and place your cylinder there.  
Rotation: I am not sure. - You could try traceing between the two sphere’s and using the contact normal for rotation.

HTH

---

<div class="post-metadata">

**Author:** ![E-Spec](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@E-Spec](https://forums.unrealengine.com/u/E-Spec)\
**Post date:** [December 12, 2015, 4:24pm UTC](https://forums.unrealengine.com/t/actor-movement-based-on-other-actors/49814/3 "2015-12-12T16:24:45Z")

</div>

Thank you, I got that part working now!  
I’ve been trying to do the rotations using vector calculations, but it seems that I’m still doing it wrong.

---

<div class="post-metadata">

**Author:** ![ryan20fun](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ryan20fun/32/1194363_2.png) [@ryan20fun](https://forums.unrealengine.com/u/ryan20fun)\
**Post date:** [December 12, 2015, 4:47pm UTC](https://forums.unrealengine.com/t/actor-movement-based-on-other-actors/49814/4 "2015-12-12T16:47:12Z")

</div>

I forgot: The first part (Subtract the two sphere’s world location -\> Normalize) gets you a move direction vector, There should be a way to get a rotation out of that(As Eular angles anyway).

HTH

Edit:  
If you want I will see what I can do.  
Perhaps you could post the end result (Blueprint or description of what you did) for other people to see.

---

<div class="post-metadata">

**Author:** ![E-Spec](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@E-Spec](https://forums.unrealengine.com/u/E-Spec)\
**Post date:** [December 12, 2015, 11:23pm UTC](https://forums.unrealengine.com/t/actor-movement-based-on-other-actors/49814/5 "2015-12-12T23:23:13Z")

</div>

So I tried fiddling some more with the blueprint and got this:

![fc89903f546ad5619776bde707bad0ee4a1abc97.jpeg](https://d1ap1mz92jnks1.cloudfront.net/images/transparent.png)

It’s still not rotating as I want it to, so I’ll just have to try some more, but I’m quite new to Unreal Engine 4 and haven’t done vector calculations in 2 years so it might take me some time.

---

<div class="post-metadata">

**Author:** ![ryan20fun](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ryan20fun/32/1194363_2.png) [@ryan20fun](https://forums.unrealengine.com/u/ryan20fun)\
**Post date:** [December 13, 2015, 7:58am UTC](https://forums.unrealengine.com/t/actor-movement-based-on-other-actors/49814/6 "2015-12-13T07:58:03Z")

</div>

I have found [this stackoverflow](http://gamedev.stackexchange.com/questions/15070/orienting-a-model-to-face-a-target) post that walks about rotating an object to face a point.

Last night I got to thinking about having N spheres with the cylinder in the middle of them.  
The algorithm (untested) is to get the halfway point between each sphere and use that point for the place of one sphere, But rotations would be a problem along with weighting the placement.  
I think I will give this a shot, For reference my cylinder will face up(so you may need to use an offset for rotation).

HTH

---

<div class="post-metadata">

**Author:** ![ryan20fun](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ryan20fun/32/1194363_2.png) [@ryan20fun](https://forums.unrealengine.com/u/ryan20fun)\
**Post date:** [December 13, 2015, 2:58pm UTC](https://forums.unrealengine.com/t/actor-movement-based-on-other-actors/49814/7 "2015-12-13T14:58:29Z")

</div>

I found [this](https://answers.unrealengine.com/questions/56888/how-to-make-something-point-at-something-else.html) answer on rotating to point

---

<div class="post-metadata">

**Author:** ![E-Spec](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@E-Spec](https://forums.unrealengine.com/u/E-Spec)\
**Post date:** [December 13, 2015, 4:38pm UTC](https://forums.unrealengine.com/t/actor-movement-based-on-other-actors/49814/8 "2015-12-13T16:38:00Z")

</div>

Wow, thank you so much, it’s now working perfectly!

Here’s my end-result for people who need it:

 ![BPMovementAndRotation2.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/8/1/810d6f4227006e33b935aed50ec8361420c9cb24.png)

---

<div class="post-metadata">

**Author:** ![ryan20fun](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ryan20fun/32/1194363_2.png) [@ryan20fun](https://forums.unrealengine.com/u/ryan20fun)\
**Post date:** [December 13, 2015, 8:01pm UTC](https://forums.unrealengine.com/t/actor-movement-based-on-other-actors/49814/9 "2015-12-13T20:01:58Z")

</div>

> [@E-Spec;436706](#):
>
> Wow, thank you so much, it’s now working perfectly!

Glad I could help 🙂

> [@E-Spec;436706](#):
>
> Here’s my end-result for people who need it:
> 
> ![BPMovementAndRotation2.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/8/1/810d6f4227006e33b935aed50ec8361420c9cb24.png)

I think I am going to have to find some way of using something nifty like this! 🙂
