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 Dalsia · Jan 20, 2018 at 03:57 AM · movementraycastladder

Strategy for "perfect" ladder movement?

Hi, everyone,

My problem has nothing to do with code I don't think, but rather with the approach to solving the problem. I have been developing my own raycast controller for the past few weeks, and one of the last features I want to implement is ladder movement. I have been successful overall in doing this, but the one issue I can't seem to solve is that once my character is about to be off the ladder and land on the platform above to which he is climbing he "bounces" very briefly, though not very high in the air, and then falls flush on the ground. This isn't a big deal, but I want to learn how to make "perfect" ladder movement like you see in most games.

If anybody has input or a strategy to solve this I'd appreciate it. The way my code works is:

  • If the character is pressing up he emits a raycast from the center of his collider.

Using OnTriggerStay2D (with the condition that the raycast from #1 has hit the ladder already):

  • If this raycast collides with a ladder the character is now in "ladder climbing mode" and can move up and down using Unity's vertical axis. Gravity is also set to 0 so he doesn't fall.

  • If the character's raycasts hit the ground while he is moving down the ladder everything resets back to normal. - If the character holds left or right while on the ladder he can jump in that direction.

  • If the character moves upward, he will go through the 1-way platform I have created, and then land on it, sometimes landing perfectly flush, but most of the time moving slightly above the platform before falling back down, making it look like he's "bouncing." This also resets everything to normal of course.

Perhaps this isn't the best solution, but it works for me. I have literally put around 60 hours into trying so many different ways to solve this issue, rewriting my entire ladder code numerous times, and maybe I'm making too difficult on myself, but I cannot figure it out. It seems like the momentum of the vertical axis is causing the bounce because if I make my movement speed higher there is a noticeable increase in the bounce. However, turning gravity back on and removing the ability to move up and down as soon as the player is no longer on the ladder (which seems like the correct solution) seems to take about .05 seconds, so the bounce still occurs about 50% of the time.

I think the true solution is to limit Y movement via raycast, but I don't know how to do this while going upward since my character has to be slightly inside the 1-way platform collider before moving all the way up the ladder.

Here's a short excerpt of the Platformer Pro asset on the asset store that does what I'm talking about.

https://youtu.be/e-ea9n4dQWQ?t=115

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

0 Replies

· Add your reply
  • Sort: 

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

138 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

Related Questions

How to move the main camera in Google Cardboard? 0 Answers

Raycasting in 2D to prevent a player from moving through walls? 1 Answer

rotate two objects around each other and then keep them moving 0 Answers

How can I make it so that my player only moves if there is no wall in the direction he wishes to move? 1 Answer

local or global position of raycasthit.textureCoord? 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