- Home /
Making an object move inside a cylindrical surface
Hello, for the past couple of days I've been trying to implement a system where a car could go inside cylindrical pipes.
Right now i am applying a big force downwards from wherever the car is standing, so basically the force is pulling the car to surface in its current orientation. This causes some random problems and not very smooth movement during turns, which you can see from the following little clip.
https://streamable.com/usll5z (slight epilepsy warning)
I would like to do this by script and maybe have the car float tiny bit above the surface where it would look like it is on the surface and get smoother movement. How would you go about implementing this?
I tried something like the following guide from youtube but it made the movement actually worse for my case.
Answer by Captain_Pineapple · Jul 09, 2021 at 09:30 AM
why use physics to "drive" at all? the user will not be able to tell if there are physics between the ground and the car or if you are just moving the car around a fixed point in space.
then you can define a trajectory through your tunnel system (you could even calculate that) and move the car along this trajectory with a fixed offset of the tunnels radius.
The only things that really need physics here are the obstacles.
Right, also for games like that it's often much simpler to use a bending shader to just make the world look curved and work with a perfectly straight cylinder. This makes all the interactions and "physics" much simpler. You just have to simulate the "bending" by changing the bending offset over time.