void Destroy()

robot_2Generated
code_blocksInput

Description

The Destroy method is used to mark a GameObject for destruction. The actual destruction of the object occurs at the start of the next frame, ensuring that any ongoing operations involving the object can complete before it is removed from the scene.

Usage

To use the Destroy method, simply call it on an instance of a GameObject that you wish to remove from the scene. This method does not require any parameters.

Example

// Example of using the Destroy method
GameObject myObject = new GameObject();

// Perform operations with myObject

// Mark the object for destruction
myObject.Destroy();

// The object will be destroyed at the start of the next frame.