RTS Blink/Flash to location Help?

Hi All,

I have been trying to workout how to, in a sense teleport the player to a new location where the mouse cursor is.

Now i have some idea that i would need maybe a trace line and worldspace to convert the new location but how i implement this is a little over my head as i have been only doing this for a few days now!

Would anyone be so kind and to show me a working solution that i could take and then adapt to my own needs please?

Also is it best practice to store movement for a player and his spell casting with in the player its self or shall i keep coding within the player controller?

Many thanks.

Now there is no official best practice or anything but in general I like to split up my coding between controller, character and some other actors like this:

Controller: Here comes all the input events and everything like that. It takes care of the rotation (via control rotation) of the character and does all kinds of checks if your input is valid and what should happen.

Character: This once then receives the input (the “What should happen” from the controller) and actually does something. Here are all variables like HP, Stamina, an inventory… this kinds of stuff. If you work with spells I would also implement those here. If you use a weapon that should be a separate actor.

Weapon: The weapon receives a fire event from the character and handles things like how fast it shoots, ammunition and stuff like this.

Now for a teleport you should do the linetrace as you thought. You will need your controller (either inside of it’s script or the controller as reference) to get the “Hit Result under Cursor” which will provide you with a Hit Result. Break that to get the location of where it hit. This is the location in 3D space where your mouse points at. You can then simply use the function “Teleport” from your character which will take care of pretty much everything. Now you still have to do some checks so you can’t be teleported into nowhere, on top of weird locations, impassable terrain and so on which is a completely different chapter and requires quite a bit…

Quite honestly. If you’re this new to Unreal and I assume coding in general you should stick to some tutorials. Maybe do the temple run clone type of thing which is a rather detailed tutorial on the unreal youtube channel. Once you’re done with that you should be able to add a few functions onto that and build on top of it and then you can come back to your completely own project. Do keep in mind that whatever you do your first few projects will not be finished. You will not even get close and when you come back in a few months you’ll just shake your head about it because it’s so horribly implemented. That’s completely normal since you learn all the time. Just keep your projects small and simple for the beginning. Like really super small… which an RTS or moba is not. Really no offense but I run in exactly the same trap and just deleted those several dozens of hours of work because it was just horrible :wink:

Cheers :slight_smile:

Hi Erasio, Thanks for your advice and wisdom on this… I do very much agree with keeping things small and that is what I’m doing here with this little project as i don’t want much init but maybe a few challenges a little above my current knowledge.

Hope you don’t mind but I’m going to PM you with few things to get me sorted which i believe you will :slight_smile:

Thanks

Hello Gasric,

I have an example that may help. This is a line trace that uses the mouse’s screen position to find the location under the mouse. You can use the hit result to get the location that you need. I hope that this helps.

Make it a great day

Will take a look at this and see how i get on, thanks very much