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 /
  • Help Room /
avatar image
0
Question by DiceMaster5 · May 19, 2016 at 01:07 PM · c#animationscripting problemcollisioncharactercontroller

Help with OnTriggerEnter Not working correctly?

I would like some helping on figuring out why this OnTriggerEnter doesn't modify the booleans gotHit and canMove. This code is supposed to allow my player to be hit by the enemy and play a staggering animation while not allowing my player to move and reduce it's health, but only the health part works.

    void OnTriggerEnter(Collider hit)
     {
         if (hit.gameObject.name == "L Hand Box")
         {
             gotHit = true;
             health.CurrentVal -= 20;
 
             if (this.anim.GetCurrentAnimatorStateInfo(0).IsName("standing_react_large_gut"))
             {
                 canMove = false;
             }
             else
             {
                 canMove = true;
             }
         }
         else
         {
             gotHit = false;
         }
     }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by PhantomSarcasm · May 19, 2016 at 01:40 PM

the first thing I do is use "print" or "debug.log" to see if it comes in if collision. proves that this coming into your first "if", I'm not sure but quisas, one of the two objects colicionar not have the active trigger or not have the regidibody ..... it sounds like an insult but small things habeses they are the first to be forgotten, remember that it objects to colicionar one must have "rigidibody" and some other either has to have the active is_triger. as I said before do not take it as an insult but first rule out the simplest things besides ..... I'm not sure this cojiendo object name spaces, usually not put spaces in the name to avoid any problems ..

Comment
Add comment · Show 3 · 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 DiceMaster5 · May 19, 2016 at 01:45 PM 0
Share

I have tested a debug.log to see if the collisions work and i can confirm that they do work and output the message. Like I said the "health.CurrentVal -= 20;" but the rest just doesn't work properly or at all.

avatar image PhantomSarcasm DiceMaster5 · May 19, 2016 at 01:53 PM 0
Share

I do not have a clear answer you I am noobster and do not have much knowledge of what it is "GetCurrentAnimatorStateInfo" forgive not be of help

avatar image DiceMaster5 PhantomSarcasm · May 19, 2016 at 01:56 PM 0
Share

That's ok, Thanks for trying to help anyways. I use "GetCurrentAnimatorStateInfo" to check if the animations is currently playing, and if it is, i make it so that the player can't move.

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

189 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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 in move make Y=1 everytime ? 1 Answer

Doodle Jump Game Platform Spawn Issue Unity2D 0 Answers

ANIMATION STRANGELY DOES NOT PLAY 0 Answers

Animation triggered by other animation, script, c# 1 Answer

I spent 6 hours and I failed to launch a ball forward? I could not figure out what is happening? 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