- Home /
Player in Spaceship
I want to realize space game on Unity3d engine. There are some huge spaceships in the void. So, I want players flying in space in weightlessness, but when they go inside any spaceship, they will be under the influence of local gravity field of spaceship (if it is in On
state).
I going to do it using addForce()
function applied to rigidbodies
of players towards spaceship floor. But with this approach Players will be only magnify to a floor, but not to stay on they feet automatically.
How can I put they on they feet the best way?
Or, maybe, anybody knows the completely different approach to solve this custom gravity fields issue?
PS: It will be a multiplayer game with many ships with different orientation in space with a lot of players in them. Each ship has it's own gravity field.
Answer by arun.pandey89 · Aug 18, 2015 at 07:06 AM
You can simply toggle UseGravity flag of rigid body to perform such scenario (Suppose ,In outer-space players are not using gravity property of rigid body and as they get inside ship turn on gravity property ) , may be i did not get the question because it's not a tricky one how i see it.
Answer by Vice_Versa · Aug 18, 2015 at 07:11 AM
when theyre outside, do rigidbody.useGravity = false; then when they are inside do rigidbody.useGravity = true;
(this might be different in unity 5, not sure but if that doesnt work try this)
gameObject.GetComponent<Rigidbody>().GravityEnabled = false;
Your answer
Follow this Question
Related Questions
Artificial Gravity 2 Answers
Problems making a glider 3 Answers
Change Gravity? Physics scaling for large objects to behave like normal ones... 0 Answers
Realistic/No gravity spaceship movement? 1 Answer
Attaching Rigidbody breaks gravity 1 Answer