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 omgStomp · Apr 03, 2012 at 11:25 PM · androidphysicsrigidbody

Rigidbody doesn't move on moving platform

Hey all!,

I've started making a game which a cube lands on a platform. However when the cube lands on the platform and the players tries to move the platform the cube doesn't move, whereas the platform does.... When the platform is no longer under the cube, the cube does fall...

I'm really confused on how to fix this.

Any help on how i can get the cube to move with the moving platform would be greatly appreciated.

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

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Kleptomaniac · Apr 04, 2012 at 02:42 PM

Possibly try parenting the cube to the platform? Not sure if its the best way to go but, give it a go:

 function OnCollisionEnter(collision : Collision) {
     if (collision.collider.gameObject.tag == "Platform") {
         gameObject.parent = collision.collider.gameObject;
     }
 }

Attach this to your cube and tag your platform as "Platform". Not sure if this will even work ...

Hope that helps, Klep

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
avatar image
0

Answer by kalvinlyle · Apr 04, 2012 at 09:46 AM

The cube needs a script that assigns it a position offset relative to the platform. I have no idea if this code will work, but it's basically what I'm doing for my game.

 public class PlatformBase : Monodevelop {
 
     Vector3 relativeOffset;
     Transform child;
     Bool riding;

     void Awake ()
     {
         child = Find("Cube");
     }
     
     void LateUpdate ()
     {

         if(child && riding)
             child.transform.position = this.transform.position + relativeOffset;

     }
     
     void OnTriggerEnter(Collider other)
     {

         if(other.name == child.name)
             riding = true;
 
         relativeOffset = other.transform.position - this.transform.position;

     }
     void OnTriggerExit(Collider other)
     {
 
         if(other.name == child.name)
             riding = false;

     }

 }
Comment
Add comment · Show 1 · 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 omgStomp · Apr 04, 2012 at 02:14 PM 0
Share

The code doesn't work :( and im still a little confused. If someone could give me a overview with javascript i'd greatly appreciate it.

avatar image
0

Answer by Datael · Apr 04, 2012 at 02:51 PM

There's a couple of things that I can think of that could cause this:

It might be because you haven't set the physics material on the platform to anything? You can set a default physics material for all objects in the Project's Physics Settings.

Another possibility: are you moving the platform by directly adjusting its transform (such as in code or in an animation)? I noticed that when I was trying this it would not always properly update the mesh's bounds and seemed to give erratic results with regard to the physics.

I'm on my phone right now so I can't check properly what may be causing the problem, nor check that my solutions will actually work for you (apologies), however, adding the objects as children to the platform is definitely not the solution.

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
avatar image
0

Answer by jorjdboss · Nov 05, 2013 at 10:58 AM

If you're moving the platform using an animated rigidbody with 'isKinematic=true', then you need to enable 'Animate Physics' under the animation component. This will let your moving platform interact with other rigidbodies(in this case your cube).

Note: This only works if you're using kinematic rigidbodies and moving them through animation curves. In case you haven't been using a rigidbody on the platform at all, keep this in mind: all moving colliders are dynamic and must have a rigidbody component attached.

Hope that helps.

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

7 People are following this question.

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

Related Questions

Object is moving slower on other device (Android) 1 Answer

How do I make this kind of follow script? 1 Answer

Rotating a Rigidbody with Physics 1 Answer

How do I connect multiple spheres using joints and make a character? 1 Answer

Shooting a cannonball. 6 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