How to make a gameObject invisible in unity

I am attempting to make a Unity gameObject invisible through code. So far I have tried (On a script attached to the gameObject I want to make invisible): this.renderer.enabled = false
this.enabled = false
this.gameObject.enabled = false
this.gameObject.renderer.enabled = false
And on my player script: other.gameObject.enabled = false
other.gameObject.renderer.enabled = false
I have also tried Destroy (other.gameObject) but it doesn’t achieve what I want from it.

Thanks for your help

It seems like you tried a lot of ways to turn the object invisible. But where exactly did you place these statements? Some functions get called automatically by Unity, while others won’t. Also, when you state that it does not achieve the effect you want, do you mean that the object does not become invisible? Or is it the way it becomes invisible (in an instant) that you don’t like? The latter requires some more work.

Here is an example of an script that will disable a GameObject in its entirety; it won’t be rendered, physics won’t affect it and Updated functions on its components won’t be executed. Do note however that this might or might not work depending on the version of Unity you are running.

using UnityEngine;

public class Example : MonoBehaviour
	public void Awake()

renderer.enabled = false; ?