I want to make an object float in 1 state, (with still an active rigidbody so it wont go trough walls) and have actual working gravity in another state. what would be an efficition way to do this? Please don’t give full scripts since I won’t learn from that, just give a few tips and I’ll be happy
Well here’s something i just thought up : lets have 2 states: state F (for float) and state D (for down) , so basically , you will just make the 2 trigger colliders(if you don’t know what a trigger collider is then it’s just a collider that you can go thru but still can detect stuff), and place them in State F and State D , and then add a script on each of them, for the State F one, just say when the object collides with the object (but can still go thru) , then disable the gravity for the object, so it can float. Similarly, for the State D collider, just make it the same but enable gravity instead of disable.
Sorry for making you read this essay , I just wrote what I thought while making this, if you have any questions, or want me to provide a script (i will add messages explain what each line does), just tell me
I already know when and how I will change the state, all I want is to know HOW to disable the gravity. Is there a certain thing like Gravity.Enabled (true) or whatever.
It is actually the thing he’s looking for, unless he’s doing 2D (then it would be gravity scale).
I got confused with all the 2D-threads I’ve been repsonding to recently, so I had Rigidbody2D in mind.
I believe you want to add an equal and opposite force at the center of gravity of the object. The force required would be the opposite of the force that gravity applies on the mass. If that isn’t clear enough I can point you to the specifics.
I understand you found a solution. However your object is not “floating”, it simply does not have gravity applied to it. Here is how to actually make it float.