RTS Control in Blueprint?

Just downloaded UE4 last night, and went through all the blue print videos today. Very fascinated by it all, and would really enjoy learning more about everything and maybe working on a couple of prototypes. With that in mind, the first thing I was wanting to learn how to do was move objects, in the mind of working on a RTS.

I’d like to start off very basic, so if I had a static mesh, how would I go about selecting it in game with a mouse selection and move it from it’s current selection to the new location selected using the mouse in game?


I apologize in advance for the bad layout in the image below. I’ve messed around a bit more, and am now able to get a static mesh to rotate (decide to start with rotation as it would be easier to track on screen).

With that being said, the mesh is rotating at an exponential speed instead of an incremental step of 1. What am I doing wrong?


I think you only need to do something like this, which will rotate the mesh by 90 degrees per second:

In your current graph the amount you rotate (NewVar0) is actually increasing each tick.

Thanks James, I’ll give that a try tonight. Quick question though, what is Delta? I’ve seen Delta Seconds, Mouse Delta, Delta Rotation and some other places. I’m a bit confused with what it is and how it’s used.

Thanks Again!

‘Delta’ usually just means ‘change in’. So ‘Delta Seconds’ is the time since last frame, ‘Delta Rotation’ means the change in rotation you want to apply. Because frame rates can vary, you need to take the frame time into account so your object moves at a constant speed.

Very cool, and good to know. That cleans things up quite a bit. Another question, why is delta seconds bing linked into the Z 90?

Also, if you wanted to say have it complete a 360 spin say every 1 second for a constant speed instead of based off of ticks how would you set that up?

Thanks again!

It is a cross product rule .

You want to rotate by 90° per sec. You want the deltaAngle to apply to your object each frame, so you multiply the angle speed by the deltaTime which is the time since last frame.
The node that connect angle speed and the delta time is a multiply node, that why it is connected together.

With this setup, it is already at a constant speed, it is not based only on tick because the deltaTime is part of the equation !

If you want to rotate by 360° per sec, just change Z 90 to Z 360.

Thanks Cripple, I think I have my head wrapped around it now.

I’ll be giving this a try tonight, along with some other things!

Another quick question :slight_smile: Last night I was able to set the transform information to the mouse’s XY location, however when I’m in play mode, the mouse acts as the camera so when I move the mouse the viewport changes. What would be the best way to un-link the mouse to the viewport movement, and display the mouse cursor so I can click on a location and move a static mesh to the location?


So I’ve looked at the mouse interaction content example and can’t seem to determine how to turn the mouse cursor on in a new project/level and how to use it for interaction.

Currently when I hit play, the mouse cursor stays hidden and when I tag the left mouse click to print mouse location it prints out 0, 0, 112. And no matter how much I move my mouse the position stays locked to this position.

What am I missing?


Turns out I was missing the game mode setup from this tutorial. Content Examples Sample Project for Unreal Engine | Unreal Engine 5.2 Documentation

I am now able to record the hit results from under the mouse when I left mouse click.

To make a mouse input based game you need to make a new Game Mode Blueprint, and a new Player Controller Blueprint.

Open the Player controller Blueprint, and go to the defaults tab and check all the relevant checkboxes that you want under Mouse Interface. Touch is referring to touch devices like smart phones or tablets.

Open the Game Mode Blueprint and under Player Controller Class click the dropdown and select the one you made.

Now we need to tell the level to use this Game mode, to do that, go to the World settings (the earth icon at the top), and find Game Mode section, now under GameMode Override click the dropdown, and set it to the Game mode you made.

Now when you play you should have mouse input.

Got a good start on moving objects now. By using the tutorial for setting up the Interactive Mouse Game Mode from here - https://docs.unrealengine.com/latest...ace/index.html

Creating a mesh, and making sure it’s changed from Static to Moveable

And by using the blueprint below.

I think the next step will have it moving instead of jumping to the location. I think I’ve actually got a halfway idea of how to do that too :slight_smile:

Thanks Shane, I must have been going through that tutorial and posting right as you posted!

man, i feel a little spoiled by having the UE devs actually posting. you guys rock!

EDIT: hey sandman? i’ll be watching this thread too as i’m extremely interested in the same.

Alright, so I’ve spent the morning trying to figure out put some movement in between the jumping :wink:

At the moment what I have below will allow the mesh to move along the x axis either up or down depending on if I click above or below the object. However, I’m also trying to get it to stop, and it’s not working at the moment, for some reason it’s not reading when the mesh equals the same location of where the mouse click was. Any help would be amazing! Thanks!!!

So I found a function it’s an “interp to”. The help text for it says it’s supposed to help with interpolating a mesh from point A to point B over time. I’m sure I’m setting it up the right way, but if it gets rid of everything I did above that’d be great :slight_smile: However right now it is jumping the object from one point to the other where I click.

Anyone know how to use the function the right way?

It is setting it right away because you are doing it on click, you would need to set it over time by using Tick or a Timeline.

Another option is to use a Timeline to drive a lerp that blends between the 2 vectors, and you would want to get the distance between the 2 vectors, and use it to set the speed of the timeline so he will travel at a consistent speed.

Thanks Shane, I’ve attempted setting it up with a Tick, and the mesh continues to jump/flicker about halfway between the origin point and destination. Below is the new setup.

I’ll take a look at the Timeline, but what’s a lerp?

Is this in the level blueprint, or a Class Blueprint? I would get the Statue’s Actor location not the Up Vector. In the above shot.

A Lerp is a Linear Interpolate, it basically just blends between 2 values based off of an Alpha value 0-1. So you just make a Float track in a Timeline, and make the curve go from 0 at 0 and 1 and 1 second.

You could try something like this.

Hi Shane, that is working much much much better. However, the object keeps reverting to the original starting location when the scene starts, even when I try to re-set the new location to the variable at the end of the timeline. Here’s what I have below. What I’d like is to be able to take in the new location of the object at the end of the timeline, is there a way for it to register the new location?