- Home /
Is it possible to swap my x Axis and y Axis on a rigidbody2D?
Im trying to achieve rotating my physics by 90 degrees, meaning x becomes y and y becomes x.
therefore I would be able to able to run up walls with my x axis taking the gravity effect instead of Y.
If you change the Gravity's Axis from code, like by default it is Y-Axis & then you can set it to X-Axis and make Y-axis 0 .. Is this method worked ?? You tried this .. $$anonymous$$ay be it will help you out but it depends upon the game play or environment.
Answer by Chadivision · Aug 27, 2015 at 12:26 PM
There are a couple of different ways, depending upon exactly what you're after. Do you want all objects in the scene to have this sideways gravity, or just one particular object?
To affect all objects, go to Edit --> Project Settings --> Physics2D, and change the gravity setting at the top. So to fall left, for example, set x to -9.81 and y to 0.
If you want only one object to fall sideways and the rest to fall down, leave the global Physics2D settings alone. Then set the sideways falling object's RigidBody2D to physics scale of 0 (eliminating the downwards gravity).
Then add a component that creates the sideways gravity on the object. You could either use a ConstantForce2D component, or write a custom script if you need more control.
Your answer
![](https://koobas.hobune.stream/wayback/20220612001447im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Aircraft Banking Rotation Problem 2 Answers
How to lock X rotation; broken script 0 Answers
Rotating rigidbodies with moveRotation along external axis 0 Answers
Preventing Rotated Jumping (C#) 1 Answer
How to rotate on slopes with rigidbody ? 0 Answers