Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Demonstrates a simple AI that follows the player when within a certain distance.
// C# script: EnemyAI.cs
using UnityEngine;
public class EnemyAI : MonoBehaviour {
public Transform player;
public float speed = 2f;
public float detectionRange = 5f;
void Update() {
float dist = Vector2.Distance(transform.position, player.position);
if(dist < detectionRange) {
transform.position = Vector2.MoveTowards(transform.position, player.position, speed * Time.deltaTime);
}
}
}Unity is a powerful cross-platform game engine used to build 2D, 3D, AR, VR, and real-time simulations for mobile, desktop, web, and consoles. It provides a full editor, rendering engine, physics, animation system, scripting with C#, asset pipeline, and deployment tooling.
Origin & Creator
Unity was created by David Helgason, Joachim Ante, and Nicholas Francis, launched in 2005 to democratize game development with a more accessible and visual engine.
Industrial Note
Unity dominates indie game development and real-time 3D industries, extensively used in gaming, AR/VR training, simulations, architecture visualization, automotive, robotics, and digital twins.