Cylinder race track

Hello.
I want to make a game in which the player rotates along the inside of a cylinder and moves forward along its lenght.
How can I make a blueprint for that, or what tutorial/s should i follow?
A good example of what I want to do is a level in the old game Jak3 where you have to get back to the city. Thank you.

The cheap way: Use a SpringArm and attach your player, then rotate the SpringArm and move it along X or Y for forward/backward.

Or you code the math yourself, which is nothing more than ‘Polar Coordinates’. You can have a value from 0-360 and if you press left/right you increase/decrease the value and with the help of the Polar Coordinates Formula you get your x and y values on the circle. Then again move it along X or Y for forward/backward.

Would be great to hear if this method worked out for you :slight_smile:

Thnak you for your help. The main purpose of this project is learning so I dont want to use cheap tricks.
How do I start coding the math by myself?I can’t fiind anything related to polar coordinates in the blueprint editor, all possible actions.

You are right, functions like FMath::PolarToCartesian (C++) are not exposed to Blueprint. However, Polar Coordinates is a math term, I really advice to google it and learn what it is. Once you understand what this math is doing, implementing those functions in BP should be easy.

If this is not an Infinite Runner, you can also research ‘spline component’, where you create your tubes and use this spline component for the forward/backwards direction of the player. Offsetting the player from the spline is still Polar Coordinates.

If the car doesn’t need to actually physics-wise interact with the track (only needs to know when it hits powerups and boost pads or enemies etc), then yes you could do this the way I did in an old pseudo 3D game I made many years ago in the style of Gyruss, where the X coordinate is cos(angle)*radius, where radius is the desired distance from center of the tunnel, and y is similarly sin(angle)*radius, and all you have to do is increase or decrease angle by pressing D and A.

This approach can work if the tunnel will always and at all points along its length, be the same width.

I wonder if the source code for S.T.U.N. Runner is available to look at?

Of course in Unreal it would be more like Z coordinate instead of Y (I was using a 2D game engine when I came up with that formula)