• News

• Industries

• Learning & Support

• Community

• Marketplace

# non planar 2D scroller

Hello everybody !
I use to work (a lot) with UDK and UE3 but I start a all new project with UE4.
That’s why I don’t have write a line of code yet but I think of what I want to do :
I want to make a 2D scroller game but I can’t accept the limitation of a planar 2D scroller. I test a bit the blueprint of the 2D scroller example coming with the kit and don’t like it.
It constrain the movement of the pawn in 2D (no change on the Y axe).

I want to have the controll of such a game but I wish my pawn “follow” or “stick” on a non planar surface (the camera follow the pawn so, that’s allright…).
I draw a little Something to make myself clear (I hope :))

While my pawn moves, it have to follow the invisible (yet existing) mesh I put in my level to give these instructions to the pawn. It will move with 2D controls but his orientation and position will be set by this mesh.

Here’s what I think of to accomplish that :

• At first, I move the pawn according to his actual orientation.
• then, I draw a trace to “detect” the mesh surface (I call it supportMesh and it has its own channel to simplify the calculation.)
• I’ve got an “Impact” now and I can get a location and an orientation (calculate with the normal of the polygone I hit with the trace).
• I can place my pawn and rotate it.

As you can see on my schematic, a problem will occurs with this solution : When the supportMesh is not planar, my pawn will walk faster than when its planar (remember Pythagore ?)
That’s why I have do few more things after getting my “impact” to have a constant speed :

• I will calculate the real position of my pawn at t=1 by getting the angle of my triangle hypotenuse
• And finally move my pawn by the good distance (speed * deltaTime)

It still very abstract for now but I will make a prototype of this to learn C++ and make my first step with UE4.
But, I found my logic a bit heavy.
If I have to do all this at each tick, maybe is it not optimised enough (one trace (or two if the supportMesh is concave) + some simple trigonometry)…

Maybe someone has a better idea… Or is my way to do this the better way ?
I saw a video on YT with Something similar to this but the pawn follow a spline and I need it to be a surface. I will look at the blueprint…

Thanks for your time and ideas, sorry about my terrible English… I hope you have understand what I mean