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 rjdfhorn2006 · Oct 29, 2011 at 04:24 PM · collisioncolliderplatformerside-scrolling

Object deforms when parenting to a moving platform.

I am trying to implement moving platforms in a side-scrolling game. I have a ball that can rotate and move freely - whenever it lands on a moving platform it deforms - the ball stretches in all sorts of ways - does anyone know how to counter this or make moving platforms work? I'm currently using the parenting method but it's not working right for some reason. This is the code I have on the moving platform:

function OnCollisionEnter(collision : Collision) { if(collision.rigidbody.tag == "Player") { collision.transform.parent = transform;
} }

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
2

Answer by Eks-Squared · May 31, 2015 at 05:51 AM

I had this same issue in the past. The problem is that the ball is taking on the scale of what ever your platform is. That means if your platform has an odd scale, the ball will be scaled the same way.

A very easy solution would be to create your own platform in an external modelling application like Maya or Blender. Keep in mind that you will have to APPLY the scale to whatever platform you create (you should scale the platform to what ever scale your player is).

When you touch the platform you created, more odd deformations will happen. Let me know if this solution works.

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 john-essy · Oct 29, 2011 at 09:23 PM

Create an Empty GameObject then parent the object to what it is you want to parent to then make the object that defects a child of the empty gameObject.

Hope this solves your problem

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 ChrisSch · May 31, 2015 at 06:26 AM

Eks Squared is correct, but if you don't want to do that, simply create an empty object with scale of 1,1,1, a collider, and make the platform a child of it, without a collider. Then when the ball lands on it, just parent it to the empty game object.

Alternatively you can leave the empty game object without a collider, and put it on the platform itself, but I'm unsure if that would work the same, as there's been a few physics changes over the years.

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 roadtofame · Dec 22, 2018 at 08:02 AM

Just had this problem and accidentally solved it. Here's the code I'm using:

     public GameObject TheLedge;
     public GameObject ThePlayer;
 
     void OnTriggerEnter()
     {
         ThePlayer.transform.parent = TheLedge.transform;
     }
 
     void OnTriggerExit()
     {
         ThePlayer.transform.parent = null;
     }

Make your player the child of an empty and set that empty as ThePlayer gameobject and your platform as ThePlatform gameobject. I assume you already have this solved but hopefully this helps someone because this took me some time to get right.

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

How to deal the 2d platform physics? 0 Answers

Triggering platform animation on colliding with Button 0 Answers

Character Controller falls through moving/rotating platforms (Not A Duplicate Post) 1 Answer

Ignore collision at high velocity. 1 Answer

What is the problem here ?( move script, c#, basic, platformer) 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