Unity 3D Game Development — Complete Beginner's Guide
In this tutorial, you'll learn about Unity 3D Game Development. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.
Unity 3D Game Development uses the same component-based architecture as 2D but adds depth — literally. GameObjects exist in three-dimensional space with Z-axis movement, perspective cameras simulate human vision, and physics engines handle collisions, gravity, and forces across all three axes using C# scripts that drive every behavior.
In this tutorial, you'll navigate the 3D scene view, create and transform GameObjects, work with lights and cameras, implement a first-person controller with mouse look and WASD movement, add physics interactions, and build a simple 3D collectible game. By the end, you'll understand Unity's 3D pipeline well enough to start any 3D project.
Why 3D Game Development Matters
3D games dominate the $200B gaming industry. From open-world RPGs to architectural visualizations, 3D environments create immersion that 2D cannot match. Unity powers over 50% of all 3D mobile games and is the leading engine for AR/VR development. At DodaTech, 3D rendering techniques from Unity inform the volumetric data visualization in DodaZIP and the interactive 3D map views in Doda Browser.
Learning Path
flowchart LR A[Unity C# Scripting] --> B[Unity 3D Game Development
You are here] B --> C[Unity 2D Game Development] B --> D[Game Physics] style B fill:#f90,color:#fff
First-Person Controller
A first-person controller requires a Camera child object positioned at eye height, a CharacterController component for movement, and a script that translates input into motion.
using UnityEngine;
public class FirstPersonController : MonoBehaviour
{
public float walkSpeed = 5f;
public float mouseSensitivity = 2f;
public float jumpForce = 5f;
private CharacterController controller;
private Camera playerCamera;
private float verticalRotation = 0f;
private float verticalVelocity = 0f;
void Start()
{
controller = GetComponent<CharacterController>();
playerCamera = GetComponentInChildren<Camera>();
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity;
transform.Rotate(Vector3.up * mouseX);
verticalRotation -= mouseY;
verticalRotation = Mathf.Clamp(verticalRotation, -90f, 90f);
playerCamera.transform.localRotation = Quaternion.Euler(verticalRotation, 0, 0);
float moveX = Input.GetAxis("Horizontal");
float moveZ = Input.GetAxis("Vertical");
Vector3 move = transform.right * moveX + transform.forward * moveZ;
if (controller.isGrounded && verticalVelocity < 0)
verticalVelocity = -2f;
if (Input.GetButtonDown("Jump") && controller.isGrounded)
verticalVelocity = Mathf.Sqrt(jumpForce * -2f * Physics.gravity.y);
verticalVelocity += Physics.gravity.y * Time.deltaTime;
move.y = verticalVelocity;
controller.Move(move * walkSpeed * Time.deltaTime);
}
}
Cursor.lockState = CursorLockMode.Locked hides and traps the cursor for FPS-style input. Mouse X rotates the entire GameObject (yaw), while mouse Y rotates only the camera (pitch) clamped to prevent over-rotation. The CharacterController handles collision response automatically.
Shooting a Raycast
Raycasting lets you detect objects under the crosshair without spawning physical projectiles — ideal for hitscan weapons.
using UnityEngine;
public class RaycastShoot : MonoBehaviour
{
public float range = 100f;
public GameObject impactEffect;
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Ray ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, range))
{
Debug.Log("Hit: " + hit.transform.name + " at " + hit.point);
Enemy enemy = hit.transform.GetComponent<Enemy>();
if (enemy != null)
enemy.TakeDamage(10);
Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
}
}
}
}
The ray starts at the camera position and travels forward. Physics.Raycast returns true if it hits any collider. The impact effect is spawned at the hit point, rotated to match the surface normal.
Physics-Based Object Interaction
Use AddForce to push objects with physics. Combine with mouse input for a grab-and-throw mechanic.
using UnityEngine;
public class ObjectThrower : MonoBehaviour
{
public float throwForce = 10f;
public Transform holdPosition;
private GameObject heldObject = null;
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Ray ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 3f))
{
if (hit.rigidbody != null && hit.rigidbody.gameObject.CompareTag("Pickup"))
{
heldObject = hit.rigidbody.gameObject;
heldObject.GetComponent<Rigidbody>().isKinematic = true;
heldObject.transform.SetParent(holdPosition);
heldObject.transform.localPosition = Vector3.zero;
}
}
}
else if (Input.GetButtonUp("Fire1") && heldObject != null)
{
Rigidbody rb = heldObject.GetComponent<Rigidbody>();
heldObject.transform.SetParent(null);
rb.isKinematic = false;
rb.AddForce(Camera.main.transform.forward * throwForce, ForceMode.Impulse);
heldObject = null;
}
}
}
Pick up objects within range by making them kinematic and parenting to the hold position. Release applies an impulse force in the camera's forward direction.
Practice Questions
- Why does the camera need to be a child of the player GameObject for a first-person controller?
- What is the difference between
Transform.RotateandTransform.LookAt? - How does
Physics.Raycastdiffer fromPhysics.SphereCast?
Frequently Asked Questions
What is the difference between a Mesh Renderer and a Skinned Mesh Renderer?
Mesh Renderer renders static geometry. Skinned Mesh Renderer handles animated characters with bones and blend shapes — it deforms the mesh at runtime based on the skeleton's pose.
Should I use Transform.position or Rigidbody.MovePosition for movement?
Use Transform.position for non-physics objects (cameras, UI). Use Rigidbody.MovePosition for physics-driven objects to avoid breaking the physics simulation. The CharacterController handles this internally.
How do I optimize 3D scenes for performance?
Use occlusion culling (bake occlusion data), LOD groups (Level of Detail), combine static meshes, use GPU instancing for repeated objects, limit real-time lights to 1-2 per scene, and enable frustum culling (enabled by default).
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro