- Home /
Roof of the builiding (physics)
Hi! I've got a question about Unity physics engine. I'm building a builiding from cubes. These cubes have rigidbody with gravity switched on attached to it. Ok, so I'm builiding walls, floor and then it's time to build roof. Ok, but I've got some problems with physics. I see that my roof is falling down. Ok - it's because I've got gravity on. So I switch off the gravity in rigidbody components of these cubes. But now they're behave very unrealistic when the ball is falling them (for example). They're flying like the cosmos stones.
Is it possible that I can paste the roof between walls without switching off the gravity?
Answer by Jeff-Kesselman · May 05, 2014 at 04:32 PM
You have fundamental contradiction here.
You want physics, but you want things in mid air with nothing holding them up.
Physics doesn't work that way.
HOWEVER there are some things you could try, I would suggest
Turn gravity off to start with.
Attach an OnCollisionEnter script that turns gravity on when an object collides with the block.
They're flying like the cosmos stones : set is$$anonymous$$inematic to true
I am afraid i don'y knwo what a cosmos stone is.
If you set is$$anonymous$$inematic to true than no forces will effect them at all. Thats kind of the brute force way to stop gravity from effecting them.
It would be better to leave them reacting to physics but with rigid body.useGravity=false so they will still respond to being hit.
Then, all you need to do is set it to true when there is a collision to make gravity effect it again.
Sorry, my misunderstanding. I assumed the roof pieces were floating away at start when the building pieces settled. Of course your solution is probably the best, upvoted.
Your answer
Follow this Question
Related Questions
How to make telephone wires 1 Answer
Edit this script so that on the second jump change the gravity to 5 2 Answers
How can I make a game object move in parabolic motion as if it were under gravity? 2 Answers
Change direction of gravity for a specific instance of a prefab 1 Answer
Setting a jump force on a rigidbody 1 Answer