- Home /
Destroy(this.gameObject) vs Destroy(gameObject)
I'm creating a space shooter game where the laser beam is destroyed when it leaves the camera's fov. Both methods are doing exactly the same thing. So is there any difference between these 2 techniques?
Answer by HenryStrattonFW · Feb 18, 2018 at 08:31 AM
No there is no difference. the keyword "this" simply is a way of the object to self reference. It's typically unnecessary to ever use unless you have things like parameters in a function that match the same name as members within the object. I tend to try to avoid this and as a result almost never use "this".
Your answer
Follow this Question
Related Questions
using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers
The name "Destory" Does not exist in the current context 2 Answers
Trying to make a simple inventory: 0 Answers
Destruct gameobject by call from another script 1 Answer
GameObject.FindGameObjectsWithTag still finding destroyed object (C#) 1 Answer