- Home /
On var enter
Hello also I had another quistion I really need help on...
I understand the function OnTriggerEnter () {}
But what if I wanted it to be a sertain object to enter a location
Could it work like this
var Bullet : GameOject;
function OnBulletEnter () {}
Would a function like that work pleas let me know thanks!
Answer by Landern · Jan 15, 2013 at 04:24 PM
You would have to implement a way of executing that function/method in your code. The OnTriggerEnter/Exit/OnCollision.... have their execution maintained by the Unity back end engine.
One way of creating this type of behavior is using Events, but this can be a hard concept for people to wrap their head around when it comes to subscribing/un-subscribing from events, let alone the execution of them. Is there perhaps a better way of asking your question, what are you trying to do with the bullet other then have a function/method execute when something/one enters the collider? If it is something like that, just use colliders or triggers on the code that is attached to the bullet gameobject.
Your answer
![](https://koobas.hobune.stream/wayback/20220613090958im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
set a var to a function in another script 2 Answers
function Start () problem!! 3 Answers
How to turn on and turn off function with button. 1 Answer
Why won't values show in inspector or print in console? 1 Answer