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 Team_26 · Feb 03, 2014 at 08:56 PM · particlesfirecall

OnControllerColliderHit function not called? [C#]

Hi! I've got a problem with the "OnControllerColliderHit". I use this function in the FirstPersonController. When the player hit a campfire, campfire must light. It's not working - the function OnControllerColliderHit is not called. Can you tell me what I'm doing wrong? Part of the script:

     void OnControlerColliderHit(ControllerColliderHit col)
     {
         if(col.gameObject.name == "campfire") 
         {
             if(haveMatches)
             {
                 LightFire(col.gameObject);
             }
             else 
             {
                 textHints.SendMessage("ShowHint", "MESSAGE");
             }
         }
     }
     
     void LightFire(GameObject campfire)
     {
         campfire.GetComponentInChildren<ParticleSystem>().Play();
 
         campfire.audio.Play();
         Destroy(matchGUI);
         haveMatches = false;
     }
Comment
Add comment · Show 3
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 Josh707 · Feb 03, 2014 at 09:50 PM 1
Share

The if statements probably aren't having their requirements met, you can use Debug.Log to check

 void OnControlerColliderHit(ControllerColliderHit col)
 {
 Debug.Log(col.gameObject.name);
 if(col.gameObject.name == "campfire")
 { //and so on
avatar image Team_26 · Feb 04, 2014 at 04:51 PM 0
Share

-_- The name is correctly... Have you got any other ideas?

avatar image Team_26 · Feb 04, 2014 at 04:55 PM 0
Share

I try your script and I find something... The DebugLog is not showing any info... How to fix it? The FPC has the charactercontroller component...

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Mortoc · Feb 04, 2014 at 04:58 PM

Typo in the function name: OnControlerColliderHit should be OnControllerColliderHit

Comment
Add comment · Show 7 · 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 Team_26 · Feb 04, 2014 at 05:06 PM 0
Share

Oh... Noob problem... Thank you very much (debuglog is showing info about collision, but my particles systems are still not playing. Can you fix this problem too?

avatar image Team_26 · Feb 04, 2014 at 05:09 PM 0
Share

UPDATE to comment: can it be caused my campfire is the child of the empty gameObject called "Builidings" and it have a lot of child (rock1, rock2 etc.)?

avatar image Mortoc · Feb 04, 2014 at 05:12 PM 0
Share

if you take the line:

        campfire.GetComponentInChildren<ParticleSystem>().Play();

and change it to

        var campfireParticles = campfire.GetComponentInChildren<ParticleSystem>();
        Debug.Log("particles", campfireParticles);
        campfireParticles.Play();

does it select the particle system component you're expecting it to in the debug log?

avatar image Team_26 · Feb 04, 2014 at 05:25 PM 0
Share

No :/......

avatar image Team_26 · Feb 04, 2014 at 05:27 PM 0
Share

I probably know what's the problem: when I collide with rock which is the child of the campfire only, the LightFire function isn't called. How can I fix it? Is it possible that can I make the one GameObject of the Parent/Child group?

Show more comments

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

19 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

Related Questions

Scaling particle emitter transform has odd results. 0 Answers

Shuriken Particles in Web Player 0 Answers

Problems with unitys Particle: Fire_Complex from the Standart assets 0 Answers

How do i make a particle emmit a fire in unity 3.x? 1 Answer

How to create shoots 2 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