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 ThatOwlGuy · Jul 20, 2012 at 03:22 AM · colliderontriggerentermeleedebug.log

This melee damage detector won't work...

Okay, I'm still not sure what doesn't work but I know that the objects are not detecting the trigger for some reason so I'll just ask if there's anything wrong with these few lines.

 function OnTriggerEnter(that : Collider) {
  Debug.Log("OnTriggerEnter() was called");
 }

This should send a message to show that OnTrigger was called but it won't for some reason, it won't happen. This is perplexing because in a script I have that monitors health, the exact same line is used and works perfectly on the player, but when I put this on another object set to "isTrigger" it does nothing.

Comment
Add comment · Show 7
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 ThatOwlGuy · Jul 20, 2012 at 03:24 PM 0
Share

also I got this weird message in the debug log. It isn't an error message so I can still run the scene but I don't know what it is and I haven't seen it before I've had this problem so maybe that's it. the error message reads: Default GameObject Tag: melee zone already registered

avatar image Seth-Bergman · Jul 20, 2012 at 11:00 PM 0
Share

$$anonymous$$OST CO$$anonymous$$$$anonymous$$ON CAUSE: one of the objects $$anonymous$$UST have a rigidbody for this to work

avatar image ThatOwlGuy · Jul 20, 2012 at 11:40 PM 0
Share

that can't be though... because this was taken from my health stat script which works just fine and neither the player or health pack have a rigidbody component

avatar image Seth-Bergman · Jul 20, 2012 at 11:57 PM 0
Share

If BOTH objects have a trigger, you need a rigidbody..

avatar image ThatOwlGuy · Jul 21, 2012 at 01:13 AM 0
Share

BOTH ojects have trigger, and I tested out your suggestion anyway and it didn't work. I think it might be a compiling error. The theory is down straight and the above lines work in my other scripts. But I'll try one more thing and see if it works... but, thanks, you really have been helpful with this.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Seth-Bergman · Jul 20, 2012 at 03:30 AM

For OnTrigger to work, the object with this script must be set to "isTrigger". Otherwise use OnCollisionEnter instead

EDIT:

OH, got it:

change if(Input.GetButtonDown("Hit")...

to

if(Input.GetButton("Hit")

GetButtonDown only returns true the first frame the button is pressed

EDIT2:

Since the question has now changed, here's the new answer-

If BOTH objects are set to isTrigger, one of them will need a rigidbody as well.. OR, just use OnCollisionEnter instead

http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html

note the section on triggers

Comment
Add comment · Show 5 · 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 ThatOwlGuy · Jul 20, 2012 at 03:43 AM 0
Share

I'm sorry, but I already know this, the object is already set to istrigger... But thanks anyway.

avatar image Seth-Bergman · Jul 20, 2012 at 03:50 AM 0
Share

add this line at the top:

function OnTriggerEnter(other : Collider){ //when you walk into

Debug.Log(other.tag); //send a Debug Log

if (other.tag == "uppermz"){ //and if other's tag is "uppermz";

etc...

as long as the other object in the collision has a collider, and is tagged correctly, this should work.. The Debug Log may provide a clue..

avatar image Seth-Bergman · Jul 20, 2012 at 03:57 AM 0
Share

Figured it out, see the edit above

avatar image ThatOwlGuy · Jul 20, 2012 at 03:59 AM 0
Share

wait, I'm sorry, what's being put in at the top?

avatar image Seth-Bergman · Jul 20, 2012 at 04:01 AM 0
Share

forget that,

change if(Input.GetButtonDown("Hit")...

to

if(Input.GetButton("Hit")

GetButtonDown only returns true the first frame the button is pressed

updated my answer above

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

AnimationEvent, Collider, OnTriggerEnter logic? 0 Answers

Melee attack comblat 1 Answer

Fog On and Off Script Help! 2 Answers

Accessing variables in enemy. 2 Answers

Creating a collider in a gameObject using only code 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