I am currently creating an endless runner game and I have come across a problem I am struggling to fix as a beginner. So far, I have set up the ability to rotate when coming across a corner and the ability to switch lanes. However, after turning a corner, there is a high chance that the player will not become centered on a lane. My idea was to add three box triggers that would split up the corner floor tile and center the player on a lane depending on which trigger is overlapped with.
However, I have no idea how to create a function which would do that. I tried creating something that would change the world location of the character and fiddled around a bit more but I am fully stumped. I have set up the tile system using the tutorial posted by the unreal team. I would appreciate any help. Thank you. Here are photos of my blueprints:
If you use tick to center the player, you donāt need to worry about any of this, I donāt think.
To get it working, just use tick ( with a vinterp ) to center the player on the pivot point axis of the current piece. Then you can add lanes, which is just an offset.
Sorry, Iām still a bit unsure on how to implement this. By āpieceā do you mean the current floor tile actor the player is standing on? I donāt really understand use pivot points and all that. I have arrow components on the three lanes of my floor tile. Is there any way I can move the player based on the location of them?
I donāt really know your setup, so itās hard to give you exact code. But letās say the player is always running forward on X, Z never changes, so itās Y you have to control.
Then, you need to home in on the Y coordinate of the arrow for the lane, a bit like this:
Ok, it turns out that itās a bit of a mare, if I assume the arrows can be pointing in any direction.
If you calculate the arrow world position, arrow forward vector and the player world position, this handy little formula will tell you the nearest point on the line of the arrow which the player should head towards:
You will probably have to omit Z, otherwise the player will be half in / out of the tiles maybe.
Youāll need to tell the player which arrow is the current one as it changes. I really donāt know how much use this be, but itās ( a little bit ) interestingā¦
hi ive just seen your Endless Runner: Centering The player answer, i just wanted to know where you get the āNearest Point on Lineā target from? is it just the target promoted if so can i see what the first imageās full blueprint is connect too?