Hello,

I am trying to make a sort of “teleport attack” where my character will teleport around an enemy then playing an attack animation and repeat this a few times (for a sort of combo).

In clear, the player will input a certain combo that allows this attack to be performed, then pressing the dedicated keybind, the player character will teleport to a random location around the enemy and hit it, and it will repeat this 4 or 5 times, each time to another random location in order to result in a sort of combo.

As I already have everything setup, the only part that I’m struggling with is each time getting a random location around the enemy, I’ve tried adding a random number to the enemy X and Y positions but it doesn’t seem to get the job done.

Help would be appreciated, thank you

Hey @H4ckeur. There are many ways to achieve what you are looking for. One option that comes to mind is instead of generating a random X, Y coordinate from the enemy’s location, you could generate a random value between -180, 180 or 0,360 and use that as an angle for the direction to teleport to. If you get 180 then your player would spawn behind the target and so on. You would also need to set a fixed (or random if you prefer) value for the distance from the target to teleport your player.

This way you get a random direction from your generated angle and then you place your player at a specified distance in that direction.

You can also come up with some tricks so that the random locations spread around the target. For example, by coincidence you could end up teleporting your player in the same space each time it teleports (or very close positions). So you could make it so that if you generated the number 60, then the next number is at least 45 degrees away from that value. In this case it would be a value higher then 105 or lower than 15.

Hope this helps

1 Like

Hello

If you have the position of the enemy, you can use as the center of a circumference.

Using RotateVectorAroundAxis you should be able to obtain a position around a circuference of the dimensions and axis that you need.

Hope it works, I adapted this from C++

Here the Reference https://unrealcpp.com/rotate-around-vector/

3 Likes

Works absolutely wonderful ! Thank you very much :DDD