Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Kejoku · Feb 08, 2014 at 09:37 PM · rigidbodygravitycharacter controller

Gravity inside a space ship

Hey there, I've been a long time reader of the answers (going on a few years now!), and I have come across something that requires someone more capable than me to figure out.

I would like to simulate gravity inside a space ship as the ship is moving. I would like the players to be able to walk around inside the ship and help the other players. I have no problem with networking this (I've already done so), but the internal gravity can't be done so easily.

I have tried to use a character controller although they cannot rotate around anything but the global Y axis, and I know that rigidbody children can't be inside a rigidbody parent. Even knowing that, I tried anyway.

I got the rigidbody character to have a constant force applying downwards along the local Y axis and then captured the velocity of the ship and applied the ships current velocity to the character while zeroing out the Y velocity. This kind of works, although in Multiplayer the characters glitch around immensely and from the point of view of the player they are vibrating.

Is there any other way to simulate gravity? i.e. probably not involving rigidbodies or character controllers.

Any advice is greatly appreciated!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image highpockets · Feb 10, 2014 at 05:38 PM 0
Share

Is the spaceship affected by gravity? And, if so, is this the reason you haven't tried manipulating the gravity vector?? I know that you can change the gravity vector (Physics.gravity), but I haven't used character controllers yet, so I don't know the problems you would face by trying to fake it based on the current gravity setting.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Kiloblargh · Feb 08, 2014 at 11:50 PM

Does the physics engine correctly simulate centrifugal force? That's what I imagine when I think of spaceship gravity; the crew compartment of the ship is rotating at a constant speed to provide 1G of downward force against the walls, you can walk all the way around and if you climb up a ladder to the center you will become weightless and flip around. Like the ship in 2001.

If you can't automatically get that effect, you could simulate it by finding the distance from the ship's Z-axis centerline in the XY plane. It might be easier to do that with two levels of transforms- one goes forward or backwards along the ships z axis to where the player is, then measure from the player to that one, and apply acceleration away from it.

I'm not sure if that's what you're talking about though.

The other way, if your spaceship has got some Star Trek style warp drive is to just apply a 9.8 m/sec/sec acceleration to everything on the -y axis. (the spaceship's local y axis, not the player's). Do it in Update, and use Time.deltaTime.

You can still use rigid bodies and colliders, just turn off their gravity.

-edit- Is there any reason why the inside of the spaceship needs to be actually inside the spaceship, and not a separate "set, " elsewhere in the scene, viewed by its own camera which you switch to when appropriate?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

FPS Character Controller with the push DOWN rigidbodies ability 0 Answers

Is moving a collider without rigidbody bad? 1 Answer

Make A Cube 'Sticky' 4 Answers

Rigidbody AddForce/Velocity & gravity - mysterious interference 1 Answer

How to Get Velocity Based Movement With Character Controller 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges