Game Objects

Abhishek Smith

Abhishek Smith

Building Outscal | Land Jobs in the gaming industry | EA, Epic Games, TCS, | CMU, IIT K

Finding GameObjects

  • GameObject.Find(): Quick but costly - use sparingly!
  • GameObject.FindWithTag(): Better performance than Find()
  • GameObject.FindGameObjectsWithTag(): When you need multiple objects

Component Access

  • AddComponent<T>(): Adding components at runtime
  • GetComponent<T>(): Getting single component
  • GetComponents<T>(): Getting all components of type
  • GetComponentInChildren<T>(): Search in children
  • GetComponentInParent<T>(): Search in parent

Object Lifecycle Management

  • Instantiate(): Spawn new objects
  • Destroy(): Remove objects
  • Destroy(gameObject, delay): Delayed destruction
  • DontDestroyOnLoad(): Keep objects between scenes

Hierarchy Control

  • transform.SetParent(): Change parent with position control
  • transform.DetachChildren(): Remove all children
  • transform.Find(): Search child by name
  • GetSiblingIndex(): Get position in hierarchy
  • SetSiblingIndex(): Change position in hierarchy

Show More