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?
Oh and since this picture I have also created an array variable that I’m adding the newly spawned asteroid objects to.
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.
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.
Can you show me a screenshot of your updated BP so I can see what you are doing? Thank you!
Sure. Here it is.
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.
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.
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?
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.
I think I will do that. Sounds like neater code and I may want to move in the future.