How to change player gravity in a 3d space?
Hi I wanted to make a proof of concept 3d platformer demo where the player (just a single player, not the environment) could change their orientation in the scene for a short period of time, allowing them to walk on surfaces other than the floor. I have attached a rigid body to my player controller to allow for the physics to happen. I also wanted this to be able to happen only when a player touches the surface and not in the middle of touching one.
Is it possible for this to be done in Unity? I've tried to search other places for answers but I could not find one.
Answer by Bouwie · Jul 08, 2019 at 10:29 AM
you can set the gravity for every rigidbody by typing Physics.gravity = new Vector(0, -1, 0);
and for changing it you on touch can look up the OnTriggerEnter Function
@Bouwie can you provide sample code please? I'm a bit new to Unity so I would like to know how I can use this.
Your answer
![](https://koobas.hobune.stream/wayback/20220612204451im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Gravity slow descent after jump 0 Answers
Order of execution: AddForce, rigidbody movement, velocity update? 0 Answers
Physics for ball on an incline: rolling up a hill if half way up 1 Answer
WheelCollider: Car on boat. Car is pushing boat. CAUSE: WheelCollider (Suspension?) 0 Answers
Start falling through ground in one frame and in the next frame everything is good. 0 Answers