- Home /
Where to attach a script
I have new object that has a sphere collider on it, I am trying not to use on huge script on the main character controller. The code is correct but not sure where to attach this new script too. When attached to the FPC the trigger events work but the Start() does not, when attached to the object the Start() works but the on trigger events do not. Now sure where I am going wrong.
Answer by Cynikal · Aug 29, 2016 at 03:48 PM
When adding a script, it has to be on a game object within the scene.
If you're saying that the "on trigger events" do not work, the simplest reasons are:
The object you're trying to manipulate isn't set as a trigger. (Look at the collider on it. There is a checkbox that says: "Is Trigger". Make sure that's checked.
The formatting of the script. OntriggerEnTeR() vs OnTriggerEnter()
As I said the On trigger events work if I add it to FPScontoller. I have an object that in the start() I set to false. Then on trigger it appears and on trigger exit it disappears. If I attach script to fps then the start() doesn't work but the on trigger stuff does. Then if attached to object. The start() works but on trigger doesn't.
Your answer
Follow this Question
Related Questions
2D Platformer - Picking Up Items & Storing Them C# 0 Answers
Trigger is not detecting Player. (2D) 1 Answer
Can't click gameobject when over another trigger? 1 Answer
Problem triggering using colliders 1 Answer
isTrigger not working 2 Answers