float DestroyAfterSeconds

book_4_sparkGenerated
code_blocksInput

Description

The DestroyAfterSeconds field specifies the duration in seconds after which the TemporaryEffect component will automatically destroy the associated GameObject. This field is useful for managing the lifecycle of temporary effects, such as visual or audio effects, that should be removed after a certain period.

Usage

To use the DestroyAfterSeconds field, assign a positive float value representing the number of seconds you want the TemporaryEffect to wait before destroying the GameObject. For example, setting this field to 5.0f will destroy the GameObject 5 seconds after the effect is initiated.

Example

// Example of using the DestroyAfterSeconds field

// Create a new GameObject
GameObject myEffectObject = new GameObject();

// Add a TemporaryEffect component to the GameObject
TemporaryEffect tempEffect = myEffectObject.AddComponent<TemporaryEffect>();

// Set the DestroyAfterSeconds to 5 seconds
tempEffect.DestroyAfterSeconds = 5.0f;

// The GameObject will be destroyed 5 seconds after the effect starts