• 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
5
Question by xt-xylophone · Apr 10, 2013 at 09:28 PM · rigidbodyvehiclespaceshipinside

Independently moving Rigidbody inside a moving Rigidbody

Hi everyone,

I only had a couple hours last night to test or figure this out and it's been bugging me all day at work thinking of a solution.

I want to have a rigidbody controller inside of another rigidbody based vehicle. So the simplest scenario would be a box with a rigidbody that moves and spins and accelerates. And inside I can have my character move using physics with the inside of the ship as it's own reference frame. So changes in velocity wont throw it around. But also since the character is physics controlled, it also knocks the ship around like when it jumps into a wall. Making the mass of the box so large that it cannot knock it around though realistic, I dont really like :P

When they are transform based movement character controllers and the cube moves using transforms and the character is a child of the box then it all works fine, but I like the natural movements simulated using a rigidbody for the box and character.

One idea ive had could be to have the rigidbody vehicle in the game area and moving around, inside it would have the character with the camera attached to it. Then FARR away from the real vehicle is a non-moving non-rigidbody copy of the real vehicle with the same character inside which is being controlled by the player with its physics based movements and restrictions. And this character just moves the one with the camera in the same way, so the player wont know its sort of remote controlling the character in the real vehicle.

I havent gone about implementing this option. It sounds fairly complicated so Id like to explore other options too. Any features of Unity I dont know about which could make this simpler?

I've sorta asked a similar question that got me to this point and I was satisfied with it earlier but Ive come back to this and am trying to extend what I can do with it.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by xt-xylophone · Jan 21, 2014 at 12:53 AM

Ok I did the solution I said in the 4th paragraph and OMFG it is such a smooth effect.

So for the record of anyone trying to make a game in space where you can walk around inside a moving vehicle and both are controlled by physics.

Have an exact copy of the colliders flat somewhere far away from your scene, I made a 'Ghost' script which set the local position and rotation of a working camera and animated body in the real ship and the collider and Off camera are controlled by the movement and looking scripts.

Comment
Add comment · Show 4 · 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
avatar image Cdngater · Jan 31, 2015 at 07:17 PM 0
Share

Hi, I like and understand your idea of a ghost script. $$anonymous$$y issue is I dont't understand how to implement. Could you give me some guidance on writing the ghost script?

Thanks Cdngater

avatar image Clonkex · Mar 22, 2015 at 06:32 AM 0
Share

Ah what a BRILLIANT idea!! Thank you so much! I've been considering what engine to use for a game I want to experiment with and it involves being able to walk around in a moving physics vehicle... and you've just solved my problem! Thanks man! And if you wanted, for example, to have the player and physics objects inside the vehicle slide back a bit under hard acceleration, you could do it manually to the ghost physics objects with forces.

avatar image kwokman · Nov 03, 2016 at 02:14 PM 0
Share

what an amazing topic with so little answers! i need to do a similar thing in my game but I'm trying to keep it simple for a slightly larger scale. Cant afford to duplicate everything, very nice trick tho!

avatar image Jolurawa · Apr 23, 2017 at 09:07 PM 0
Share

Excellent solution dude!

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

13 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

Related Questions

Truck-Trailer Hinge Joint 0 Answers

How can I keep my character controller from affecting a rigidbody? 1 Answer

How do I keep rigid bodies from sliding when applying fake gravity based on moving parent? 1 Answer

Help me with the A* pathfinding. 0 Answers

Smoothing Rigidbody movement over a bumpy track 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges