Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 AndrewBrown123 · Jul 23, 2018 at 03:27 PM · 2dcollisionplatform2d animation

Moving Platform issue

Hello, My issue is that when I get on the moving platform my character's animation will start to freak out and flicker like crazy. I found out that it was shrinking every second frame when hitting the OnCollisionEnter2D and stops when the player jumps off the platform. The Player in the Hierarchy also jumps around like crazy from being a child of the platform too not being one.`

 void OnCollisionEnter2D(Collision2D other){
     if(other.gameObject.tag == "Player"){
         Debug.Log("On The Platform");
         other.collider.transform.SetParent(transform);
     }
 }
 void OnCollisionExit2D(Collision2D other){
     if(other.gameObject.tag == "Player"){
         Debug.Log("Off The Platform");
         other.collider.transform.SetParent(null);
     }
 }`  

This is the first time this has happen to me. I thank anyone that comes along to help. Thank You.

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
0

Answer by Stratosome · Jul 23, 2018 at 03:40 PM

Hiya! :D

Alrighty, so if I were to guess what the issue is here, it's because as the platform is moving and the player is on the platform, there are brief instances where the player actually STOPS COLLIDING with the platform triggering the OnCollisionExit2D function, but because the player is still over the platform, they will fall back on to it and trigger the OnCollisionEnter2D. Using OnCollisionEnter/Exit fires off once when something either collides or stops colliding, and for this type of thing you are doing, it is going to be imprecise. I would recommend using OnTriggerEnter2D and OnTriggerExit2D instead of the collision ones. With these, you can define an area around the platform (probably just right above it where the player stands) and as long as they are standing inside of that area, it isn't going to jump back to OnTriggerExit2D and freak out like you described. It is a lot easier to handle the OnTrigger functions than the OnCollision ones. Look in to those and see if that helps. If not, let me know and I'll come up with something else useful to say hah.

Comment
Add comment · Show 2 · 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 AndrewBrown123 · Jul 23, 2018 at 04:53 PM 0
Share

Thank you for the reply. I did what you said and changed the OnCollisionEnter2D/Exit with OnTriggerEnter2D/Exit but it still didn't fix it. So made a new sprite at it's original size and found that if you shrink something then make a object a child of that object when the game is playing it will shrink that child object to it's size i.e making my sprite freak out the way it's doing. So I just have to make the platform sprite small before importing it into Unity. Big Thanks.

avatar image Stratosome AndrewBrown123 · Jul 23, 2018 at 07:22 PM 0
Share

Oh okay, glad you have something figured out! Just changing the OnCollisions to OnTriggers wasn't all you had to do though. You would need to add colliders to the platforms and then make them triggers (in the inspector window) for this way to work.

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

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

Related Questions

One-way platform's side causes collision with Platform Effector 1 Answer

Unity2D collision problem 3 Answers

Bullet Trail not destroying on collision 0 Answers

Collision between Character Controller and Box Collider 2 Answers

Object jumps through roof when holding "Up" button? 1 Answer


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