- Home /
moving at certain circumstances
hi i am making a first person shooter and i have some troubles. i wanted destructible walls so i made a wall existing of various blocks. i gave every block a life variable so when the bullet collides with it the health goes down and i want to make the block destructible or movable when healt reaches 0. i want the block to have a rigidbody and being affected by gravity so that when the underlying block is gone the block falls down but i also want it to be movable when the block's health reaches zero so attaching a rigidbody at that time isn't an option so my question: is there a specific line of code i can use to let the block be immovable by the bullet but stil affected by gravity and let it become movable when health reaches zero?
Answer by ScroodgeM · Jul 23, 2012 at 09:34 PM
easy solution:
make to rigidbodies a great mass until it has some health. these block will be hard to move but it can fall. after health reaches zero, make a real mass - this will make it movable by others and keep possibility to fall
pro solution:
make blocks without rigidbody at all. once one of these blocks is reaches zero health, cast a SphereCast from block position to found nearly positioned blocks and enable rigidbodies on all found blocks. after blocks stops moving you can disable rigidbodies again to decrease CPU load.
Your answer
Follow this Question
Related Questions
Turn Gravity on when collision occurs 1 Answer
Trouble with OnCollisionEnter and Exit 1 Answer
Ragdollize kinematic rigidbodies 0 Answers
hit.normal cube 0 Answers
Gravity.cs help? 3 Answers