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 Kith · Jul 09, 2010 at 04:11 PM · characterplatformermovingstuckplatforms

2D Platformer Moving Platform Question

So I'm making a 2D platformer for iPhone, and I have some moving platforms here and there. The way I've implemented moving platforms is by adding a trigger on top of the platform (Making the trigger have slightly less width than the platform so a character shouldn't get stuck on the platform), and OnTriggerEnter the player will be parented to the platform. It works beautifully until I realized that if the player misses the platform slightly while the platform is moving towards him, the player moves inside the platform and the game starts glitching o.O

I think the solution may have something to do with Rigidbodies, so that the platform will push the player aside as opposed to having the player pushed into the platform. However, rigidbodies caused even more glitches (the player model would scale way up, and the platform will start spinning everywhere.

Any help would be greatly appreciated.

Comment
Add comment · 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 spinaljack · Jul 09, 2010 at 04:15 PM 0
Share

the platforms don't need rigid bodies, rigid bodies are only for simulating physics and seeing as floating platforms have very little to do with physics you should just use solid colliders.

avatar image spinaljack · Jul 09, 2010 at 04:17 PM 0
Share

What you can do is make the trigger much taller than the platform and then when the player enters the trigger have the player's local y position snap to the surface of the platform. This will stop the player missing the trigger and also stops floating players. Unparenting when the player exits the trigger will be fine.

avatar image Kith · Jul 09, 2010 at 04:24 PM 0
Share

@spinaljack - Actually, I believe the problem does has something to do with physics. I don't think I'm being very clear :-. Okay, what I mean is...let's say you've got a moving platform (shaped like a cube). There is a trigger on top of the cube that parents the player to that cube. That handles the player moving with the platform, and that works fine. The problem arises when the player collides not with the TOP of the platform, but with one of the sides of the platform. If that happens, and the platform is moving towards player, then it will not move the player with it. The player will just

avatar image Kith · Jul 09, 2010 at 04:26 PM 0
Share

get stuck on the side of the platform, and slowly get...consumed lol.

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Archangel3d · Jan 13, 2011 at 03:32 PM

You could "fudge" it so that when your character sets off the OnTriggerEnter, the script matches the character's root Y position (at his feet) to the platform's Y position, causing him to "blink" high enough to be standing on the platform.

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 runevision · Jan 13, 2011 at 03:55 PM

For something like a moving platform you should use a Kinematic Rigidbody - i.e. a Rigidbody with isKinematic set to true.

NEVER move an object with a Static Collider (= no Rigidbody or CharacterController) and certainly not on a per-frame basis! It both has a massive performance penalty and doesn't work correctly together with other Rigidbodies.

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 Spy-King · Nov 01, 2015 at 01:27 PM

@Kith The video link below will help you. It helped me make my character controller stick to the moving platform.

https://youtu.be/t6Xr6iRMWII

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

1 Person is following this question.

avatar image

Related Questions

2.5D platformer main character collision 1 Answer

How to trigger a Moving Platform with a collider? 2 Answers

Moving character on a moving ground 1 Answer

Help Needed with Blender animations 4 Answers

Moving character to a specific point ? 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