# Spawn and Move an Object

**URL:** <https://forums.unrealengine.com/t/spawn-and-move-an-object/300102>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [November 28, 2014, 5:56pm UTC](https://forums.unrealengine.com/t/spawn-and-move-an-object/300102 "2014-11-28T17:56:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_a5c37dd7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a5c37dd7](https://forums.unrealengine.com/u/anonymous_user_a5c37dd7)\
**Post date:** [November 28, 2014, 5:56pm UTC](https://forums.unrealengine.com/t/spawn-and-move-an-object/300102/1 "2014-11-28T17:56:38Z")

</div>

I have an object in my game that moves towards a player’s starting position, and the same object spawning when I press a key. I want to have the newly spawned object moving towards the player but no matter how I manipulate the level blueprint, it doesn’t seem to be doing it. Can anyone tell me what I need to connect these two blueprints?

 ![22434-urealproblem.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/f/f/0ff80326098621b9eebec0b29925e41de66e5e9a.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a5c37dd7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a5c37dd7](https://forums.unrealengine.com/u/anonymous_user_a5c37dd7)\
**Post date:** [November 28, 2014, 6:13pm UTC](https://forums.unrealengine.com/t/spawn-and-move-an-object/300102/2 "2014-11-28T18:13:23Z")

</div>

Oh and since this picture I have also created an array variable that I’m adding the newly spawned asteroid objects to.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b9532c9a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b9532c9a](https://forums.unrealengine.com/u/anonymous_user_b9532c9a)\
**Post date:** [November 28, 2014, 8:43pm UTC](https://forums.unrealengine.com/t/spawn-and-move-an-object/300102/3 "2014-11-28T20:43:36Z")

</div>

Hi CB flood,

Currently your time is doing nothing and you are not telling the spawned actor to go anywhere. All you have it doing right now is spawning at a pre-determined location. to get it to move, drag off of the return value and create a “simple move to actor”, with the Goal being player location. You can also set a timer to run this so that the asteroid continues to try to get to the player location. To do this, create a timer and give it a function name and time. Set the Looping bool to true. Plug this into your “event begin play” node. Then create a custom event and give the custom event the same function name as your timer. Now on this custom event, create a simple move to actor with the return value from your spawnActor Asteroid\_C node, and the goal should be the player location. Now every time your timer loops it should send the asteroid after your player. The reason I suggesting you use a timer instead of tick for this is to avoid having the asteroids movement framerate dependent.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a5c37dd7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a5c37dd7](https://forums.unrealengine.com/u/anonymous_user_a5c37dd7)\
**Post date:** [November 29, 2014, 4:31pm UTC](https://forums.unrealengine.com/t/spawn-and-move-an-object/300102/4 "2014-11-29T16:31:16Z")

</div>

Hi, thanks for replying. When I pull out the return value of my spawn actor class, and try to make a simple move to location, the simple move to actor automatically links it’s goal to my spawn actor node. Likewise if I try to attach it to a preexisting Simple Move to Actor it only allows me to attach it to the goal, not the controller or activation one.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b9532c9a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b9532c9a](https://forums.unrealengine.com/u/anonymous_user_b9532c9a)\
**Post date:** [December 1, 2014, 7:25pm UTC](https://forums.unrealengine.com/t/spawn-and-move-an-object/300102/5 "2014-12-01T19:25:56Z")

</div>

Hi ,

Can you show me a screenshot of your updated BP so I can see what you are doing? Thank you!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a5c37dd7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a5c37dd7](https://forums.unrealengine.com/u/anonymous_user_a5c37dd7)\
**Post date:** [December 2, 2014, 11:34am UTC](https://forums.unrealengine.com/t/spawn-and-move-an-object/300102/6 "2014-12-02T11:34:35Z")

</div>

Sure. Here it is.

 ![22716-urealproblem.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/b/3/6b3e5e598e6df05c40ecaea29e30b8de8fa6e969.png)

I’ve added in something to destroy my object and the timers you suggested but that’s not really important. What I want to do is connect the bottom portion of my blueprint to the middle portion. The middle portion works for moving and object where I want it but doesn’t work for multiple asteroids created in real time.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b9532c9a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b9532c9a](https://forums.unrealengine.com/u/anonymous_user_b9532c9a)\
**Post date:** [December 4, 2014, 7:52pm UTC](https://forums.unrealengine.com/t/spawn-and-move-an-object/300102/7 "2014-12-04T19:52:05Z")

</div>

Just to clarify, you have tried attaching the “Get Controller” output to the “Simple Move to Actor” that you have highlighted in the image but it is not properly working?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a5c37dd7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a5c37dd7](https://forums.unrealengine.com/u/anonymous_user_a5c37dd7)\
**Post date:** [December 4, 2014, 8:03pm UTC](https://forums.unrealengine.com/t/spawn-and-move-an-object/300102/8 "2014-12-04T20:03:34Z")

</div>

I’ve managed to (somehwat) circumnavigate the problem by moving the function to the asteroids own draw graph rather than the level draw graph. The reason I didn’t do this earlier is because I couldn’t get the player’s position but since I don’t intend to move my player I’ve just set the Move To Location at 0,0,0.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b9532c9a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b9532c9a](https://forums.unrealengine.com/u/anonymous_user_b9532c9a)\
**Post date:** [December 5, 2014, 4:01pm UTC](https://forums.unrealengine.com/t/spawn-and-move-an-object/300102/9 "2014-12-05T16:01:37Z")

</div>

Hi ,

In the asteroid actor, you should be able to get the player pawn’s location by using a “Get Player Pawn” or “Get Player Character” node and from there drag off and get a “Get Actor Location” node. However, if you are not moving the pawn simply using 0,0,0 as you have should work just fine.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a5c37dd7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a5c37dd7](https://forums.unrealengine.com/u/anonymous_user_a5c37dd7)\
**Post date:** [December 5, 2014, 4:19pm UTC](https://forums.unrealengine.com/t/spawn-and-move-an-object/300102/10 "2014-12-05T16:19:25Z")

</div>

I think I will do that. Sounds like neater code and I may want to move in the future.
