
Master advanced C# scripting in Unity with a practical toolkit for moving, rotating, and transforming objects in 3D space, while delving into vectors, coordinate spaces, transformations, and quaternion rotations.
Assumes intermediate Unity users and familiarity with C# basics, guiding you to apply core programming concepts to motion, rotations with quaternions, and orbiting objects using companion files.
Demonstrate moving objects in a three-dimensional scene using vectors, local versus world axes, and the transform's position, rotation, and scale, then apply script-based motion along the object's forward direction.
Move a Unity object forward in the direction it’s looking by using the forward vector multiplied by speed and updating its transform each frame.
Move an object in the direction it's looking by multiplying speed with delta time, ensuring frame-rate independent motion across machines in Unity.
Learn how Unity gizmos visualize object range and forward vector in the scene, and implement a gizmo show script to draw a green sphere and blue line in the editor.
Use the gizmo's draw icon function to render a texture as an icon at an object's position, importing a carrot texture into assets/gizmos and assigning it as a UI sprite.
Explore how to rotate objects in Unity using quaternions, covering yaw, pitch, and roll, how to orient objects from any direction, and how to inspect rotations in the editor.
Learn to rotate an object around the x, y, and z axes via a c# script using quaternion.euler and vector3.up, then spin it over time with deltaTime and quaternion multiplication.
Rotate a game object to face a moving target using look rotation and vector subtraction, by exposing a transform target, assigning it in the inspector, and updating rotation in update.
Learn to rotate a game object toward a target using quaternions, replace look rotation with rotateTowards, and control rotation speed with delta time for realistic, gradual pursuit.
Learn to orbit a cube around a pivot in Unity by using vectors and quaternions, an orbiter script, and cross-platform input to maintain a constant pivot distance.
Advance your mastery of Unity game scripting with C# by building player controls, NPC handling, gravity, and collisions, and applying vectors, vector projection, and damping to create smooth, responsive gameplay.
Demonstrate third-person player movement using keyboard controls and the transform component, driven by quaternion and vector multiplication for rotation and movement, and highlight the issue of passing through solid objects.
Adapt the player to physics by attaching a character controller, using simple move with a forward vector, and updating in fixed update to align with Unity physics and gravity.
Explore the distinction between local space and world space in Unity, and learn how local forward vs transform forward (Vector3.forward) behave, including converting vectors between spaces for accurate movement.
Explore when to use local space versus world space for object displacement in Unity, and learn to convert local displacements to world space via transform direction or quaternion rotation.
Learn to implement jumping and gravity with a character controller in Unity, using forward movement, jump force, and a distance to ground check via raycast on the ground layer.
Use quaternion spherical interpolation to smoothly rotate objects toward a target with damping for a gradual stop. Implement look rotation and a damped rotate toward function for turrets and ships.
Learn how vector projection and clamping guide a gun turret along a defined track to continuously face the player in Unity, using a gizmo line and the pulse project script.
Explore a terrain hovering project in Unity by building a capsule controller that follows terrain contours, rotates to face movement, and uses keyboard input to navigate.
Learn to implement player movement on terrain in Unity with a C# script: read keyboard input, move forward and sideways via transform with delta time, and attach to the player.
Apply a downward physics raycast to offset a moving capsule from the terrain by a fixed distance, enabling real-time height matching and terrain-conforming elevation.
Cast a downward ray from the capsule to intersect the terrain and obtain the hit polygon’s normal. Use spherical interpolation to rotate the capsule so its up vector aligns with that normal, at 5 degrees per second, maintaining alignment as the terrain climbs and dips.
Kick off this course on game scripting with C# in Unity, expanding fundamentals to contexts. Script Mecanim animated characters, serialize data for safe states and data exchange, and track items.
Explore character animation in Unity, blending idle, run, and turn while colliding with level objects, using standard assets and humanoid rig features, and preview how C# scripting supports this.
Explore root motion in Unity animations, diagnose unintended world displacement, and correct x-axis offsets by adjusting root transform rotation and pose settings to keep motion straight.
Configure a blend tree in Unity to animate character. Build an animator controller, set an idle state, and configure a blend tree with two parameters for two axes of movement.
Map two parameters, horizontal and vertical, to a Blen tree with nine motion fields to control a character's idle, walk, and run animations, and prepare to drive them from script.
Drive a blend tree in Unity with a C# script that reads horizontal and vertical input and sets animator parameters with damping, and convert strings to hashes to optimize update.
Learn to persist data in Unity by saving the player's last position and rotation to a JSON string at the end of a scene and restoring it at scene start.
Convert the object to a JSON string and save it to a Unity persistent data path file, then load the JSON to restore position and rotation.
Plan an inventory system in a Unity scene, demonstrating how collected items appear in a bottom panel and are tracked in the Ventry folder, with item order affecting display.
Create a Unity inventory UI from scratch using a screen space overlay canvas with scale with screen size at 1920x1080, assign UI layer, and add a bottom panel for items.
Create an inventory panel in Unity by adding a canvas panel, using a horizontal layout group with padding and spacing, and adding item slots with sprite icons.
Configure collectable inventory items in Unity using the inventory item script, on trigger enter, and the inventory class to add items (cylinder, sphere, cube) and icons to the Ventry panel.
Create a singleton inventory in Unity that collects items, disables their colliders and renderers, and places icons in the first available inventory slot.
Explore advanced C# scripting in Unity for games, focusing on twin stick shooter controls, the relationship between mouse cursors and touch locations, dynamic objects, and object pooling for performance.
Learn a flexible object-picking approach in Unity using the event system, physics raycaster, and a custom handle clicks script to print a cube's name when clicked.
Handle pointer clicks in Unity 5 by implementing IPointerClickHandler and onPointerClick, using PointerEventData to log the clicked object's name, and connect with an event trigger for visual scripting.
Discover twin-stick shooter controls in unity by turning a turret to face the mouse cursor and firing ammo prefabs. Learn why simply using instantiate isn't always ideal.
Turn the turret to face the mouse cursor in a twin-stick shooter. Use a cursor face script to convert screen coordinates to world space and compute look rotation.
Create ammo in Unity by turning a sphere into a prefab, attaching the mover script, and using a kinematic rigidbody so projectiles travel along their forward vector without gravity.
Create an ammo generator that instantiates the ammo prefab at the spawn point when the fire button is pressed, using the spawn point's transform position and rotation.
Master ammo pooling in Unity by precreating a pool of ammo objects at scene start, activating them when needed and hiding them on reuse to avoid expensive instantiate calls.
Learn to script ammo in Unity 5 by attaching c# script to the ammo prefab, using on enable and invoke to deactivate it after a set lifetime, and canceling invokes.
Create an ammo manager in Unity to generate a 100-object hammer pool from a prefab at level start, using a singleton to control visibility for creation and destruction.
Create an ammo pool by initializing a singleton ammo manager, populating an array to the pool size, and instantiating ammo prefabs as children of the manager in Unity.
Implement a reusable ammo pool in Unity 5 using a queue to activate the first available ammo when firing, then hide it and return it to the queue.
Implement the M-O manager to spawn ammo via a static function that dequeues and activates ammo at the turret, then requeues it for recycling and returns the spawned transform.
Explore advanced game scripting with C# in Unity, covering AI and NPC logistics, proximity detection and line of sight, pathfinding, and finite state machines for varied enemy behavior.
Leverage unity to build an AI-controlled NPC that wanders, sees the player, chases and attacks, then returns to patrolling, using a first-person controller and the standard assets.
Define the enemy’s view with a sphere trigger collider in Unity and detect the player with a line-of-sight script using OnTriggerStay.
Learn to implement an NPC field of view in Unity using a center line, a 45-degree angle, and a can-see target flag updated on trigger stay to detect the player.
Implement line of sight in Unity with a field of view check and a ray cast to detect obstacles, tracking last known position and applying strict or loose visibility.
Generate a navigation mesh to let the npc patrol the level and avoid obstacles. Attach a nav mesh agent to the character and adjust the agent radius.
Create an enemy navigation system that uses a nav mesh agent to chase a destination, building a waypoint patrol that moves between points while avoiding obstacles.
create a single destination object animation to patrol between points, using constant tangents for abrupt jumps and slow the animation to smooth the patrol.
Learn to implement a finite state machine in Unity to drive an enemy through patrol, chase, and attack states using a C# enum and a current state variable.
Complete a finite state machine for a Unity AI enemy by implementing patrol, chase, and attack states as self-contained code routines with yield-based update loops.
Implement a state machine for an AI enemy with patrol, chase, and attack states. A public current state property updates private state, stops routines, and activates correct behavior in Unity.
Explore how the enemy AI finite state machine handles patrolling, chasing, and attacking, while a serialized health script tracks player health and triggers death at zero.
Explore how the AI enemy uses line of sight checks, state management (patrol, chase, attack), and a navmesh agent to pursue and engage the player, including path calculation.
Build a Unity enemy AI with a finite state machine that chases using last known sighting, tolerates momentary sight loss, attacks when in sight, and returns to patrol if unseen.
Learn how to create believable game worlds and behaviours by scripting gameplay in C#. In this comprehensive 3dmotive course targeted at intermediate users, instructor Alan Thorn demonstrates advanced C# scripting techniques and their underlying concepts for solving real-world development problems. Understand core mathematical ideas, like Vectors and Quaternions, for making objects move, rotate and change predictably. See how to apply C# for implementing line of sight functionality, artificial intelligence, collision detection and lots more. In addition, see how to work with large amounts of data, how to understand coordinate systems and spatial problems, and how to customize the Unity editor to work the way you need it to. By the end of this course you’ll have established a highly valuable foundation for coding confidently with C# to develop sophisticated games that are impressive - and marketable.
(Students - please look under Section 1 / Lecture 1 downloads for the source files associated with the lesson.)
More about the Instructor:
Alan Thorn is a game developer, author and educator with 15 years industry experience. He makes games for PC desktop, Mobile and VR. He founded 'Wax Lyrical Games' and created the award-winning game 'Baron Wittard: Nemesis of Ragnarok', working as designer, programmer and artist. He has written sixteen technical books on game development and presented ten video training courses, covering game-play programming, Unity development, and 3D modelling. He has worked in game development education as a visiting lecturer for the 'National Film and Television School', as a Lead Teacher for 'Uppingham School', and is currently a Senior Lecturer at 'Teesside University' where he helps students develop the skills needed for their ideal role in the games industry.