GameObject Extensions
Get Or Add Component
This retrieves an existing component of type T or adds it if it doesn't exist.
Reset Transform
This resets the transform of a GameObject to zero position, no rotation, and a scale of one.
Is Grounded
This checks if the GameObject is grounded using a raycast.
Add Force Towards
This applies force to a Rigidbody in the direction of another GameObject.
Set Velocity Towards
This sets the Rigidbody's velocity towards a specified target position at a given speed.
Get Closest
This method is especially useful in situations like AI targeting, where you need to find the nearest point of interest (enemies, items, etc.) to a specific GameObject.
Is Visible To Camera
This checks whether the GameObject is currently visible by any camera.
Set Layer
This sets the layer of a GameObject using its name.
Has Layer
This checks if a GameObject's layer matches a specified layer name.
Set Tag
This sets the tag of a GameObject.
Has Tag
This checks if a GameObject's tag matches a specified tag name.
Add Child
This adds a child GameObject to a parent GameObject.
Clear Children
This removes all child GameObjects from a parent GameObject.
Get Child By Name
This retrieves a child GameObject by its name.
Get Child By Tag
This retrieves a child GameObject by its tag.
Last updated