Reputation: 59
I'd like to make an aquarium where diverse fishes are existing.
I tried not to let fishes pass through cubes, but the OnTriggerEnter
function doesn't work even if objects enter the trigger.
These pictures represent each of whale and cube inspector factors.
Upvotes: 0
Views: 13194
Reputation: 31
I also want to add "Physics -> Auto Simulation = false" this will absolutely stop measurements.
Upvotes: 0
Reputation: 2884
You only need to add a Collider
to your fish, (at the same level of the Flock
script, or on a child GameObject
).
OnTriggerEnter will only fire when a Collider
enters a Trigger Collider
See MonoBehaviour.OnTriggerEnter(Collider)
Upvotes: 1
Reputation: 7615
I guess you are missing some of these things:
EDIT:
From your latest screenshot, your flock script that is supposed to detect the trigger is not attached to your GameObject. Simply attach it to one of the two GameObjects that is supposed to collide together.
Upvotes: 6
Reputation: 1
Ok so I've had this problem before. Something that helped me A LOT was to MAKE SURE YOU CREATE YOUR SCRIPT IN YOUR OBJECT. It's just easier.
If you didn't create your script IN your object then when you typing void OnTriggerEnter, there won't be any suggestion to finish the word 'OnTriggerEnter'. If you create it in the object than it should suggest to finish the word as 'OnTriggerEnter'.
Or you're just missing a collider or rigidbody. :)
Upvotes: 0