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 Mathpro · Dec 07, 2016 at 08:58 PM · colliderscollision detectionplatformsmoving platformchild-to-gameobject

How to detect if the player object is on top of a moving platform?

So I am making a 3D game with platforms moving diagonally, horizontally and vertically. Whenever my player collides with a platform and it's velocity.y is equal to 0 for 2 consecutive frames, the player object becomes a child to the platform so that it moves with the platform but it can also move on the platform.

So far so good, it works perfectly on horizontal platforms and platforms moving upwards. However, if the player object falls down on a platform moving downwards it velocity.y doesn't reach -0 so it doesn't stick to the platform and I get this ugly bouncy effect where the cube(player.object) falls to the platform, stops, the platform continues, the cube falls again and so on.

One way to fix this is to remove the condition for velocity.y == 0 for 2 consecutive frames and instead check it in a single frame. But doing it this way will make it possible for the player to stick with the platform even when touching it from below the platform. For example, the platform is coming downwards towards the player, the player jumps and touches the bottom of the platform, its velocity.y is nullified and the player becomes a child of the platform. This is a scenario we want to avoid.

Any ideas how to fix this? :/

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 lylat · Dec 08, 2016 at 08:14 AM

Its possible for you to raycast downwards upon colliding (Checking if it is below you) or by checking by comparing the character Y position and the platform Y position. If it is the moving platform then you could set it to freeze the players Y position to be relative to the position of the platform.

Velocity is still an issue however and you could make it stick to 0 as long as the character is on top of the object through raycast or collision exit checks etc. Your characters jump can remove the constraint on your Y position.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Audio trigger when FPS walks into things, walls, doors etc 0 Answers

Bullet/Projectile Collision Question 2 Answers

Translating an object along a line until it collides with other objects 1 Answer

Why when i move the player object through the door the ontriggerenter/exit event are not fire ? 2 Answers

Collidiers intersection 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