✅ Step-by-Step to Create the Script:
- In Unity, right-click in the Project window →
Create > C# Script
. - Name the script:
BallScript
.


Double click the C# script file to open the code via Visual Studio (refer to previous article for the installation: Unity #0002 – Install Unity and Visual Studio – Wonderful Code See)
When you create a new C# script in Unity (e.g., BallScript.cs
), Unity automatically generates a default template to help you get started. Here’s what the default code looks like:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BallScript : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
🧠 Explanation:
using
statements: Import Unity-related namespaces.BallScript
class: Inherits fromMonoBehaviour
, which is required for all scripts attached to GameObjects.Start()
: Called once when the script is first run (good for initialization).Update()
: Called once per frame (used for regular per-frame logic like input handling).
This template is intentionally minimal so you can build custom behavior step by step.