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 Kwibble · Dec 18, 2014 at 01:22 PM · 2d-platformerladder

2D Ladder Climb Through Platforms

I have written a lidder climbing script that works fine (uses interfaces and triggers), except for when it comes to climbing through platforms whilst on a ladder.

Basically, I want to be able to climb up a ladder and then pass through the platform and move onto the top of it. That's easy. Just set the player's collider2D.isTrigger to true. (Refer to figure 1 for correct non-collision) Here is the code I am using

Then the problem is coming back down the ladder. I pass straight through the platform at the bottom of the ladder and move/fall through it. (Refer to figure 2 for incorrect non-collision)

Figure 1:

Figure 1

Figure 2:

Figure 2

Thanks Unity community, Kwibble

ladder_problem_3.png (82.9 kB)
ladder_problem_2.png (83.9 kB)
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 Taxen0 · Dec 18, 2014 at 04:02 PM 0
Share

you could have a bool the tracks if you are moving up or down, and in you collision detection add it to the if-case.

you could for example change the bool according to the difference in the transforms Y-coordinate between the frames.

feel free to post some actual code if needed =)

avatar image MrSoad · Dec 18, 2014 at 04:21 PM 0
Share

Another possible way is to have a collider that blocks each of the ladder holes(you would have to make a hole, collider gap, in the platforms). If you are climbing on the ladder then the these colliders are disabled for that ladder, if you are not climbing on that particular ladder then that ladders hole block colliders are enabled. With all your other platform colliders enabled all of the time to stop the fall through like in pic 2(that platform would not have a hole cut in it's collider setup).

avatar image Kwibble · Dec 18, 2014 at 07:42 PM 0
Share

@Taxen0 Ah, updated with a link to the code - sorry about that

@$$anonymous$$rSoad Wouldn't that lead to horrible movement because the character would lurch around everywhere?

I think the main problem is the fact that I am using triggers on the ladders. This means when any part of the player enters the ladder's area, he can be climbing the ladder.

avatar image MrSoad · Dec 18, 2014 at 07:48 PM 0
Share

No it should not affect movement in any way at all... It may not be the best way of doing this... It was just a quick idea :)

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Ferb · Feb 04, 2015 at 10:50 AM

I think instead of changing the player's collision, you should change the platform's. You could know to only change the collider for the platform if the ladder is overlapping it. Since in the top picture, the ladder is overlapping the platform, the player would be able to get through, but in the bottom picture, the ladder isn't overlapping the bottom platform, so the player would stand on that platform fine.

Depending on the type of game, enemies may still want to stand on those platforms, so instead of disabling the platform's collision altogether, in the long run it is probably better to use Physics2D.IngoreCollision to just cancel the collision between the player and the platform and reenable it afterward.

I expect the ladder would also need another trigger just above the platform, to tell the script not to cancel the collision straight away, just to cancel the collision anytime the player wants to come down the ladder.

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 hawken · Nov 09, 2015 at 01:03 PM

Using two different types of platform layer (solid, pass through) would solve this problem. When your player is on the ladder let it pass through the "pass through" layer.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to detect CompositeCollider2D shape center? 0 Answers

Unity2D - Creating multiple Ladders that centers the player? 1 Answer

Physics2D checking if object goes out of OverlapArea 1 Answer

climb speed changes drastically when game window is not maximized 1 Answer

2d Ladders snap to middle? 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