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 nu51313932 · Oct 20, 2017 at 05:08 PM · collider2dontriggerexitbooleans

[FIXED.]I can't make the bool = false when I exit the collision (OntriggerExit2D)

This is the climbing tree code.

Help me please. Already set the animation bool climbingCheck = true when enter the collision but it does not false on exit the tree collision(2d). Sorry for my noob English too.

Where should I put climbingCheck = false; on the code part? .......................................

 void Update()
     {
 
         //use for space spcaebar 1 time to highest jump.
         //Input.GetAxis("Jump")>0  use for hold space bar to jump higher until max.
         if (grounded && Input.GetButtonDown("Jump"))
         {
             audiox.PlayOneShot(Jump, 0.3f);
             grounded = false;
 
             anim.SetBool("isGrounded", grounded);
             rigid2d.AddForce(new Vector2(0, jumpHeight));
         }
 
 
 
 
         if (canClimb)
         {
 
             //CLIMB UP
             if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
             {
                 anim.SetBool("climbingCheck", climbingCheck);
                 //rigid2d.velocity = new Vector2(0, climbspeed);
                 climbingCheck = true;
                 climbing = true;
                 transform.Translate(Vector2.up * 0.5f * Time.deltaTime);
                 rigid2d.isKinematic = true;
                 rigid2d.velocity = new Vector2(0, 0);
 
                 //CLIMB Animation
                 anim.SetFloat("Direction", 1);
                 OnLadder = true;
 
                 anim.enabled = true;
                 maxSpeed = 0.7f;
                 if (!facingRight)
                 {
                     flip();
                     return;
                 }
                 canClimDown = true;
             }
             else if (Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.DownArrow))
             {
                 anim.enabled = false;
             }else
             {
                 climbingCheck = false;
             }
 
 
             if (canClimDown)
             {
                 //CLIMB DOWN
                 if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow) && rigid2d.isKinematic == true)
                 {
                     climbing = true;
                     transform.Translate(Vector2.down * 0.5f * Time.deltaTime);
                     anim.SetFloat("Direction", -1);
                     anim.Play("Player_climbing", -1, float.NegativeInfinity);
                     OnLadder = true;
                     // rigid2d.velocity = new Vector2(0, -0.48f);
                     anim.enabled = true;
                 }
                 else if (Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.DownArrow))
                 {
                     anim.enabled = false;
                 }
             }else
             {
                 climbingCheck = false;
             }
 
         }
 
         if(canClimb == false)
         {
             rigid2d.isKinematic = false;
         }
 
 
     }
 
 
     void OnTriggerEnter2D(Collider2D other)
     {
         if (other.tag == "LadderStart")
         {
             canClimb = true;
         }
     }
 
     void OnTriggerExit2D(Collider2D other)
     {
         if (other.tag == "LadderStart")
         {
             canClimb = false;
             //rigid2d.isKinematic = false;
             anim.enabled = true;
             climbingCheck = false;
            
         }
     }
Comment
Add comment · Show 6
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 tmalhassan · Oct 20, 2017 at 05:14 PM 0
Share

You want to set an animation's bool to false?

avatar image nu51313932 tmalhassan · Oct 20, 2017 at 05:21 PM 0
Share

I did set. The bool = true when I enter the collision but when I exit it do not set to false.

avatar image tmalhassan nu51313932 · Oct 20, 2017 at 05:23 PM 0
Share

I don't understand. What do you exactly want to do? Please explain in details...

Show more comments
avatar image Cheeseless · Oct 20, 2017 at 06:41 PM 0
Share

When you're testing this out, do you let go of W or Up before leaving the collider?

Additionally, can you try doing this: if(canClimb == false) { rigid2d.is$$anonymous$$inematic = false; climbingCheck = false; } on line 78?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by nu51313932 · Oct 21, 2017 at 04:11 AM

FIXED.

I need to put anim.setbool....

in function OnTriggerExit2D

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

73 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

Related Questions

OnTriggerEnter and Exit seem to not be working 1 Answer

Question regarding OnTriggerExit2D for destroyed objects 1 Answer

Why is OnTriggerExit2D called before OnTriggerEnter2D? 1 Answer

Unity3D: Entering a trigger disables a few bools for no reason 2 Answers

OnTriggerExit2D not working on android (but works in editor) 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