Question: What Language Does Unity Use?
Answer
Unity primarily uses C# for scripting. C# is a versatile, modern programming language developed by Microsoft as part of its .NET framework. It was chosen for Unity due to its easy-to-understand syntax and powerful features, making it suitable for both beginners and experienced programmers.
Here's an example of a simple C# script in Unity that moves a GameObject when an arrow key is pressed:
using UnityEngine; public class MovementScript : MonoBehaviour { public float speed = 5.0f; // Speed of the GameObject void Update() { if (Input.GetKey(KeyCode.RightArrow)) { transform.position += Time.deltaTime * speed * Vector3.right; } if (Input.GetKey(KeyCode.LeftArrow)) { transform.position += Time.deltaTime * speed * Vector3.left; } } }
In this script, Update
is a method called once per frame by the Unity engine. The Input.GetKey
method checks for key presses, and transform.position
modifies the position of the GameObject to which this script is attached.
While C# is the primary language used in Unity, Unity also supports JavaScript (also known as UnityScript) and Boo, but these languages are deprecated and no longer recommended for use.
Was this content helpful?
Other Common Game Engines Questions (and Answers)
- Can You Use C# in Unreal Engine?
- What Games Use Unreal Engine 5?
- Is Unreal Engine Open Source?
- What is Unreal Engine?
- Can Unreal Engine make 2D games?
- Does Unreal Engine Use C++?
- Does Unreal Engine Use Python?
- What Language Does Unreal Engine Use?
- Does Unreal Engine Use JavaScript?
- Does Unreal Engine work on Linux?
- How Do I Uninstall Unreal Engine 5?
- Is Blender or Unreal Engine Better?
Free System Design on AWS E-Book
Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.
Start building today
Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.