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?