Answer the question
In order to leave comments, you need to log in
Problem with OnCollisionExit?
The problem is that OnCollisionExit does not work when the object on which my object is standing is deleted. I searched for a similar problem on the Internet, but the only solution I found was a script on the object being deleted with the OnDestroy method and calling the delete event in it. As for me, this is not very convenient (since this script must be thrown on each destroyed object, and there are many of them), and perhaps there is a better way.
Here is the current solution:
Object to be removed:
static public event Handler Destroyed;
void OnDestroy(){
Destroyed?.Invoke();
}
void Start(){
DestroyedGameObject.Destroyed += (gameObject) => Exit(gameObject);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question