How to make objects follow the player?

I got the blueprints for making an object follow the player. My problem is that the objects kind of keep moving back and forward and not stay in a position when I move the player.

So, my idea is to keep the objects in a specific location when following the player. For example, when I move forward or sideways the objects should keep the same distance. The problem I have is that if I turn left or right quickly then the objects go crazy and take a big jump back a few feet then start to move slowly to the player again. I just want to keep them close to the player, but at a specific distance and always stay that way.

Also, I noticed that when i do those aggressive turns (I control the left and right movements with the mouse) that’s when the objects kind of take big breaks like racing cars and stop following the player, but then proceed to follow it slowly.

I thought the whole point of AI moveto was you just call it once, ie, not on tick.

I can give you a nice script for making an ‘object’ follow the player if you like, but are we actually talking object or a pawn with AI?

I have everything set up already. I got the objects (actors) following the player. The problem is what I mentioned above. They tend to go crazy and not follow in the same pace when the player turns left or right.

The problem you’ve got is you have to either use AI or tick, you can’t use both, they’re screwing with each other.

Try this:

307346-ezgifcom-optimize.gif

2 Likes

I did post on this, but I think it’s being withheld for some totally unknown reason.

Basically you can’t mix tick and AI move because they fight each other. Try this:

307346-ezgifcom-optimize.gif

It can be easily modified to follow what you tell it to


I combined both blueprints. I added your blueprints to the even thick and used my blueprints as well. I works but only for the first object. Once the other objects start spawning they don’t follow the player like this first one. They start to go crazy and lose directions.

I’ll upload a short video of the issue. I just don’t know how to fix it. I’m still learning blueprints in UE.

Hey, thank you for the answer. This does works in an extent. It does exactly what I want, which is to always follow the player at the same speed and direction. The problem I have with this is that my blueprints allows the object to spawn behind each object. For example, the first object spawns behind the player and follows the player. The second object spawns behind the first object and follows the first object and so on. This only makes one object to spawn and not do what I had.

The concept is similar to a trail. You walk and you leave a trail. The blueprints you provided me works, but not the way I wanted. Another thing is that when I turn left or right the object as well turn left or right. I don’t want that, but I want the objects to follow the path/trail of the player.

https://drive.google.com/file/d/1gmacn4uUayXaVf0NrygvSq698P-WIXUr/view?usp=sharing

In the video you can see the first object following the player (the black dot). It follows it smoothly, but then when the second object spawns it doesn’t follow the first object that smoothly. It starts jumping back and forth. At the end of the video you can see that the last few objects make a mess and crash with each other.

Ok, it’s a little bit more fiddly. Let me show you the result first:

307338-ezgifcom-optimize.gif

They can spawn in, you can have as many as you like, the new one always follows the last one.

It’s done using the game instance, and a bit more blueprint.

1 Like

This is the BP for the follower:

I’ve also attached it so you don’t have to put it all in ( just copy from the text file and paste into the blueprint window ).

[link text][2]

It stores a reference to the latest spawn in the game instance. If it’s empty ( will be for the first one ), it follows the player.

1 Like

So, this is for the game instance and not for the object’s blueprint?
Do I still leave the first blueprints you gave me for the objects or use these one instead?

You have to make a game instance and just put the variable in it ( type actor ).

You also need to tell the project to use your game instance in the settings:

I just spawned a new ball every time I pressed O ( level BP ):

307354-levelbp.jpg

No, this is in the object. The game instance has nothing in it apart from the variable:

■■■■, sorry. It won’t work if I don’t use AI Move To. There might be something else somewhere that is making your blueprint not to work properly. I have several stuff in this project. I can’t post them all here since it’s too much. I just know that the problem has to be with the actor/object, but I think I have to use the AI.

Here’s a link to the project:

https://drive.google.com/file/d/15xJNHAq-3JR6lXtPuh_-7TybZbGQmw1F/view?usp=sharing

EDIT: Hold on, ignore that, that’s was a packaged version. Gimme a minute


Ok:

https://drive.google.com/file/d/1wwsfDVA3z85xPjS_kPVYUQkdNx8fo_o0/view?usp=sharing

I can’t get this thing to work. The problem with this is that I need the AI and without it your blueprints don’t even work properly. When I include the AI in the blueprints the objects spawn just fine and they follow the player in trail. However, the objects/actors keep bumping with one another and jump away from the player. I just want them to keep a distance between each other and always stay that way if I’m turning any direction.

Also, I have more stuff added in the whole project, which can be the reason why your blueprints don’t work properly. I just can’t put everything hear and it will take me some time to find exactly what’s causing it. I do know I can fix this problem from within the actor’s blueprints.

I play it. It works perfectly. How can I open it for editing? It only opens the game window.

I’m going to try your blueprints once more and see if I can get it working this time.

Another problem. The amount of objects spawning seems to be limited. Instead I have an object that when I step on it creates the actor, but at some point even after stepping on the object for several times the actors are not spawning anymore. It appears to be random. Sometimes the max is 10 and other times I can spawn 13.

EDIT: I think I fixed it. I can’t tell since I haven’t spawn that many objects. What I did was simply to add the “pawn” from the Get Actors Rotation to the Target for Set Actor Rotation.

I’m making it so that you can change to the pawn and see what the pawn sees. But when I change to it it flies through the map instead of staying behind the player, how can I fix this?