- Home /
walking inside curved surface
Alright i'm working on a scene where the player has to be able to walk along the inside of a giant cylinder. I'm unsure how to go about this. I can't turn off global gravity because other scenes need the normal gravity.
Ive looked into spherical gravity and ray casting but I have no idea how to implement the latter and the former doesn't work for what I need. I also thought about moving the cylinder under the player, not sure if that would work or if it would cause performance issues as it has a lot of object on it's inner surface.
I just need a way to stick the First Person controller to the surface so they can walk around and jump regardless of their orientation. So basically gravity emanating from the central point out. Ive been battling with this for a while and my brain is fried. I usually don't get answers on Answers but hey it never hurts to try.
This is still an issue I am having a hard time figuring out.
This is still an issue and I have not come any closer to figuring it out. I have lost all hope in Unity Answers actually being helpful but i'm at a loss so I will continue to ask questions into the void and not expect a helpful response.
I'm still in need of help.
I'm now thinking the easiest option would be to have the cylinder rotate as the character walks along a specific axis, so if the character walks "up the side" it's just rotating under them to give the illusion of walking up the side.
However i'm not sure how to do that.
Still having issues here, Just need to figure out how to move along the inside a curved surface. Bonus points if it works as the tube is rotating.
Answer by dbchest · Jul 13, 2019 at 07:31 AM
@cydonia my suggestion is to use custom script to disable the gravity to the player's Rigidbody. I would log that moment with a boolean, at which time you will need to simulate gravity along the correct axis. according to my research, gravity is applied in unity via simple Vector3 along the y-axis at a value of -9.81, so if you disable the player's "use gravity" option for his Rigidbody and replace it using the "AddForce" method within "FixedUpdate" you should be able to convincingly emulate gravity along a different axis. try each force mode to find the most suitable.
Alright That's a good start, however I have no idea how to do that. the issue is I know what I would like to do but no idea how to do it. $$anonymous$$ind of like if I need to get out of prison and when I ask for help I'm just told "simply get out of prison" but in my head.
At this point I'm thinking an easy option would be to rotate the cylinder on it's axis as the player controller moves simply bypassing the need to change gravity. But despite knowing what I need to do I have no idea how to script it. $$anonymous$$y C# is very basic.