• 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
Question by Anykey · Sep 16, 2011 at 01:22 PM · rigidbodyplatformmovingslip

Rigidbody on a platform

Hey!

I know the question is already asked here , but the answer is not clear

I want to make my rigidbody objects moving with the platforms ? How can I do that , i've tried checking use Kinematic on the platform , the rigidbody stays better on the platform but it slips quickly though even when the motion of the platform is very slow.

Thank you for reading.

Comment

People who like this

0 Show 4
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 GameGuy · Sep 16, 2011 at 01:34 PM 2
Share

parent your rigidbody temporarily to the plattform, when he enters it

avatar image asafsitner · Sep 16, 2011 at 01:36 PM 0
Share

Try applying physics materials to the platform and the rigidbody

avatar image Anykey · Sep 16, 2011 at 06:01 PM 0
Share

I've tried that

function OnCollisionStay (TheCollision : Collision) { if(TheCollision.gameObject.tag == "Plateform"){ Debug.Log("NNNNNNNOOOOOOOOOO"); transform.parent = TheCollision.transform ; } }

it works , but I don't know how to separate it from the platform when the cube is out of it, i've tried transform.parent = null; and transform.DetachChildren(); but neither work :(

avatar image GameGuy · Sep 18, 2011 at 11:01 AM 0
Share

what about unparenting it on user`s input.

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by FLASHDENMARK · Sep 18, 2011 at 11:22 AM

 function OnCollisionStay (hit : Collision) { 
     if(hit.gameObject.tag == "Plateform"){
         transform.parent = hit.transform ; 
     }else{
         transform.parent = null;
 }

That should add you as a child under the platform and it should separate you from the platform when you are no longer on it.

Comment
MKeiNll
jossai1

People who like this

2 Show 6 · 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 LegionIsTaken · Sep 18, 2011 at 11:24 AM 0
Share

You mean transform.parent = hit.transform; right? ;)

avatar image Anykey · Sep 19, 2011 at 01:25 PM 0
Share

Thank you so much

avatar image Mokhan94 · Oct 02, 2012 at 06:34 AM 0
Share

Is there anyway to change the parent so it only follows its position. because my object scales as well as moves with the object. I think the problem is because my platform is animated. so i only want to parent its position.

avatar image FLASHDENMARK · Oct 02, 2012 at 02:36 PM 0
Share

The problem is most likely not that your platform is animated, but that your platform (or perhaps also character, don't know) is non-uniformly scaled. It is a know problem. The guys behind Unity also explains it here:

http://docs.unity3d.com/Documentation/Components/class-Transform.html

Under "Performance Issues and Limitations with Non-Uniform Scaling"

You should scale your platform (perhaps also character) so that their X, Y and Z values are uniform e.g (3, 3 ,3) or alike.

avatar image Mokhan94 · Oct 03, 2012 at 04:15 AM 0
Share

Thank you. Ive gotten it to work. Also, is there a way to make the parenting more accurate. beacause when i am in the air. It still seems to be parented to it so sometimes when its moving away from me. and i jumpoff in the opposite direction. its give me a pull towards it.

Show more comments
avatar image

Answer by hannesdvl · Mar 08, 2013 at 05:12 PM

Moving using only Rigidbody.MovePosition and Rigidbody.MoveRotation in FixedUpdate fixes the slipping and gives a very smooth and accurate simulation.

From the docs: http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.MovePosition.html

For kinematic rigidbodies it applies friction based on the motion of the rigidbody. This lets you simulate moving platforms with rigidbodies sitting on top of the elevator. If you want other rigidbodies to interact with the kinematic rigidbody you need to move it in the FixedUpdate function.

Comment
TMPxyz
Alcheset
whisker-ship
LukeNukem44
StuwuStudio

People who like this

5 Show 5 · 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 Kevin KidsAndI · Oct 25, 2013 at 10:04 PM 0
Share

This worked perfectly in a 2.5D platformer I am developing with a rigidbody based character. I did have to set IsKinematic=true on the platform' rigidbody or objects would fall through the elevator platform.

avatar image LukeNukem44 · Aug 19, 2018 at 08:44 AM 0
Share

hannesdvl — Thank you so much for the correct answer.
I've been looking for this for a long time.
It's exactly as simple as you said, and as the unity page says which you linked to.
That page also has other useful information on it.
The platform has to be a Kinematic body and it moves characters that are on it.
It's genius!!! Far more efficient than the silly parent-child temp fix. LoL
Works a whole lot better. Thank you so much!!!

avatar image mrmeizongo LukeNukem44 · Oct 11, 2018 at 01:00 AM 0
Share

When I follow the example in the unity page my platform teleports to the location. I'm looking for a back and forth motion and my FixedUpdate script looks like this. void FixedUpdate () { if(rgb2d.position == (Vector2)wayPointA.position) destination = wayPointB.position; else if(rgb2d.position == (Vector2)wayPointB.position) destination = wayPointA.position; rgb2d.MovePosition(destination + velocity * Time.fixedDeltaTime); }

velocity is set to new Vector(1.0f, 0);

What am I doing wrong and how did you get yours to work? Thank you.

avatar image LukeNukem44 mrmeizongo · Oct 11, 2018 at 08:18 AM 0
Share

You don't want to move the object by destination, only by the velocity you desire.

Show more comments

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

12 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

Related Questions

Something on a moving platform 2 Answers

Parenting a player to a rigidbody platform 0 Answers

Prevent Player to push Rigidbody 0 Answers

movement inside a train problem 1 Answer

Platform and RigidyBody 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