Hi, we are making a game similar to rocket league and everything is fine for now except gravity problem. How can I smoothly drive on the walls of map? As you can see I tried a trigger to apply force on negative direction to gravity but there should be better option for this. Someone done that in unity but theres no source code… Example: RocketLeague In Unity GIF | Gfycat
@Ardaaytac If you Raycast straight down you can calculate the normal of the object underneath you at that point. Provided you have good normals on your object you can set gravity to the inverse of the normal’s with a lerp to prevent shaking.
the video looks like it is just using the natural physics from the game enjine you could pry just adust the bounciness and setting of the rigidbody to achieve whats going on in the video. if you want the car to “stick” to the walls like when driving around a corner like shown in your picture I would try approaching it by getting the negative transform.up of the car.
and mix it with negative Vector3.up (standard gravity) based on the speed of the car. this would make the gravity pull in the bottom facing direction of the car as it tilts. I would think you would only want the alternate gravity direction to apply as the car goes faster. disable gravity in the inspector and try something like this in fixed update:
float grav; public float gravamount;//<--use this to adjust gravity amount float f; float carspeed; //<-- number should be between 0-1 and get bigger as the car goes faster grav = -transform.up*carspeed; f = 1f-carspeed; f=f*-Vector3.up; grav+=f; grav=grav* gravamount; rigidbody.AddForce(grav);