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 /
This question was closed Jan 11, 2019 at 11:44 AM by LittleLozza12 for the following reason:

The question is answered, I posted what I did to get it to work.

avatar image
0
Question by LittleLozza12 · Jan 08, 2019 at 09:53 AM · ladder

Can anyone help me fix my ladder?

I am trying to make a ladder and there are no errors being displayed but it doesn't work. When the rigidbody of the player collides with the 2D collider of the ladder, the gravity should turn off. I have tried 2 equals instead of 3 and also:

     if (canClimb === true) {
         print("WORKING");
         //var rb = RigidBody2D;
         
         rb.gravityScale = 0;
 
         if (Input.GetKey(KeyCode.UpArrow)) {// && canClimb == true) {
             transform.Translate(Vector3.up * 5 * Time.deltaTime);
         }
     }
     else {
         rb.gravityScale = 1;
 
     }
 
     //if (Input.GetKey(KeyCode.Space)) {
     //    transform.Translate(Vector3.up * 5 * Time.deltaTime);
     //}
 
 
 }
 
 function OnTriggerEnter2D (LadderCol) {
     print("Enter");
     if (tag === "LadderCollider") {
         canClimb = true;
     }
 }
 
 function OnTriggerStay2D (LadderCol) {
     print("Stay");
     if (tag === "LadderCollider") {
         canClimb = true;
     }
 }
 
 function OnTriggerExit2D (LadderCol) {
     print("Exit");
     if (LadderCol.tag === "LadderCollider") {
         canClimb = false;
     }
 
     
         //if (Input.GetKey(KeyCode.UpArrow)) {
         //    transform.Translate(Vector3.up * 5 * Time.deltaTime);
 }
 

Thanks.

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

3 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by LittleLozza12 · Jan 11, 2019 at 11:43 AM

I just changed it slightly and put it in a new C# file instead of a Javascript one and it worked. I then added it to the player and my ladder now almost fully works.

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 Klarzahs · Jan 08, 2019 at 10:04 AM

Heya,

there are no errors when I run it

What about your debug messages? Do they get displayed, aka does the trigger event actually happen? If not, check the following things:

  1. Is the rigidbody an actual rigidbody2d? I dont think a 3d rb can collide with a 2d collider

  2. Did you have a look at the collider matrix at the end of the page? Not every combination of RB and Collider actually send trigger messages. There is a difference between "OnCollisionEnter()" and "OnTriggerEnter()".

I also assume that both objects are on the same layer, or that the layer collision is enabled.

Comment
Add comment · Show 6 · 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 LittleLozza12 · Jan 08, 2019 at 10:42 AM 0
Share

I don't have any debug messages which is why I'm not sure if it knows it's collided. The rigidbody is definitely a 2D one and the collider is a box collider 2D. I have tried changing the ontriggerenter to oncollisionenter but still nothing. They are not on the same layer but my sprite/character works with my other colliders as the ground and platforms are colliders on the same layer as my ladder but I'm able to walk along them all. Thanks.

avatar image Klarzahs LittleLozza12 · Jan 08, 2019 at 10:49 AM 0
Share

@LittleLozza12 Does your player have a Collider as well? If you look at the matrix again, a static collider (aka your ladder) only fires collision with a rigidbody collider (aka a rb with a collider)

avatar image LittleLozza12 Klarzahs · Jan 08, 2019 at 11:57 AM 0
Share

Yeah, my player also has a collider. And it's set so that it's always active, not on trigger like my ladder is.

Show more comments
avatar image
0

Answer by upasnavig90 · Jan 08, 2019 at 10:11 AM

hi @LittleLozza12 , according to your description i guess your trigger is not working right? please check how much time your player is taking to reach the ladder, and check the sleep threshold of the ladder, one of the reason can be your ladder's rigidbody is going in the sleep state while the player is reaching there. if it is so, try reducing the distance and check the if the trigger is working or not. sleep threshold you can check here-> edit/project settings/ physics

Comment
Add comment · Show 1 · 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 LittleLozza12 · Jan 08, 2019 at 10:43 AM 0
Share

Thanks, I've just checked the sleep threshold for all my colliders and rigid bodies and changed them but that made no difference either.

Follow this Question

Answers Answers and Comments

98 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

Related Questions

Stoping character with Platformer Controller script attached. 2,5D ladder. 1 Answer

How to make a simple ladder? 3 Answers

Create scripts to climb a ladder 0 Answers

Ignore Collision Layer, 2 Answers

How to check if the player is at the top of the ladder? 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