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 /
This question was closed Dec 13, 2016 at 03:40 PM by Brylos for the following reason:

I found out that the problem is I'm not referencing it correctly.

avatar image
0
Question by Brylos · Dec 13, 2016 at 01:38 PM · networkingprefabtrigger

Trigger on player controller prefab not working?

I have a playercontroller prefab that get's spawned in by my network manager when a player joins a server. It has a trigger that is attached to it as a child, but it only seems to only work as soon as the player spawns then doesn't work after that. I know it has to do with the fact that it's on the prefab. I put the script on a trigger that is in my scene and it worked fine. I need the trigger on the player prefab to be able to constantly tell if an object with the tag "ball" is in it's triggerzone. Does anyone have an idea how to get it working? Thanks in advance.

Here's the code I have for the trigger:

 ///////////////////////////////////////////
 public static int Triggered;

 void OnTriggerEnter(Collider Trigger)
 {
     Debug.Log("TriggerDetectsObject");
     if (Trigger.gameObject.CompareTag("Ball"))
     {
         Debug.Log("TriggerDetectsBall");
         Triggered = 1;
     }
     else
     {
         Triggered = 0;
     }
 }
 void OnTriggerExit()
 {
     Triggered = 0;
 }
 ///////////////////////////////////////////
Comment
Add comment · Show 5
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 sumitb_mdi · Dec 13, 2016 at 02:40 PM 0
Share

Is it the problem of the static keyword you added for your "Triggered" variable. Because it will be common for all the objects having this script.

avatar image Brylos sumitb_mdi · Dec 13, 2016 at 02:54 PM 0
Share

No. The debug.logs only show up right at the start if something is colliding with it, then don't work at all afterwards. So that tells me it's the ontriggerenter and exit voids where the problem is occurring.

avatar image sumitb_mdi Brylos · Dec 13, 2016 at 03:07 PM 0
Share

You need to change :

 OnTriggerExit ( )

To :

 OnTriggerExit(Collider other)

As per the documentation OnTriggerExit takes an argument.

Show more comments

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

127 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

Related Questions

Unity Network Spawning Prefabs 0 Answers

Clones destroying each other. 1 Answer

Sync Mecanim Trigger over network 1 Answer

Setting the playerPrefab of network manager dynamically 1 Answer

HELP! Both players rotate their cameras towards the same direction?? 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