Teleport in direction player is facing 3D sidescroller?

Hi all,

I’m pretty new to Unreal and scripting in general and I’m looking for some advice. I’m trying to get my feet wet by making a simple 3D sidescroller where the player character can teleport (sorta like nightcrawlerish I guess). I put together a blueprint and got my character teleporting but he will only teleport in one direction.

Looking at my script I think I know what the problem is but I have no idea what the solution is (The problem being that after button press I have it calculate the end destination by only looking at the player’s current location + 200px.). Is there a function I should be calling to find player’s current rotation before saying how far he should jump in the direction he’s facing?

I’ve added the blueprint and any help would be appreciated.

Well you already got the rotation.

Just check if he’s closer to looking right or left and deepening in this add or subtract your jump distance.

If your turning off the character is instant you could also do a “get forward vector” which will give you the vector your character is looking with the length of one unit.

Multiply that with your teleport distance and you have again the result.

I hope this helps.

Cheers

Ok almost got it, the only problem is doing the “Get Forward Vector” solution now it’s also multiplying the X and Z which sends may character into the background. Is there a way to ensure it only multiplies the Y direction?

Here’s my updated blueprint.

That’s why I said if your turning is instant.

Anyway you can try something like “break vector”, “make vector” and only input y there. Then divide that vector by its length so you get again a vector of one unit.

Try multiplying the Forward Vector with your Teleport Range (Float * Vector).

Grab the Actorlocation and add the result of the multiplication to it. This should be your new vector.

If you always only want the Y axis, why do you use the forward vector at all? You could just use a basic (0,1,0) vector and maybe change him to (0,-1,0) when the character faces the other direction. Although the forward vector should be (0,1,0) if your character is really facing this direction. So multiplying it with the range and adding it to the location vector, like i said above, should not move him in X and Z direction.

But i would recommend to not just teleport him. Better make a Line Trace in forward direction first. If you have a wall or ramp in the range, he will teleport straight through it or? (: