- Home /
physics.gravity with tilt game
Am making a tilt game by applying gravity on a marble which makes it move on the plan in this case the maze.
The ball have a rigidbody with mass set to 1 .The plane model have 2 parts the plane and the walls .
the plane have a metal material and smooth sphere colider unchecked .The walls have a custom material with dynamic and static friction set to 0 and both friction and bounce combine set to minimum .
the problem now is that if the marble is at a corner where it colid with 2 edges of the wall or if i manage to keep the device leveled long enough for the marble to be still it will get stuck .
Turning off and on the smooth sphere colider on the wall will unstuck the marble any idea what might be causing this ?
the code am using for moving the marble is
// Move object in XZ using accelerometer (home button at right hand)
var speed: float = 2.0f;
function Start(){
}
function Update(){
var xmovment: float = -Input.acceleration.y;
var zmovment :float = -Input.acceleration.x;
Physics.gravity= Vector3(zmovment*5,-15,xmovment*5);
}
If you can't be bothered to use proper capitalization and punctuation, I can't be bothered to read your question and provide help.
Answer by aldonaletto · Feb 12, 2013 at 02:42 PM
I suspect that the rigidbody went to bed: when a rigidbody stands still for a while, it goes to the sleep mode. Try this solution:
function Update(){
if (rigidbody.IsSleeping()){
print("Wake up little Suzy!");
rigidbody.WakeUp();
}
...
how did i miss this thank you very much you saved my life been trying to fix this for like a week or so
$$anonymous$$an I have been trying to resolve that problem for 3 days now, Aldonaletto you are the boss !!!
Your answer
![](https://koobas.hobune.stream/wayback/20220613092555im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
tilt control for jump 0 Answers
Physics on a Ball 1 Answer