Unity 2D Platformer Tutorial #12 | Accessing Variables In Other Scripts

Опубликовано: 20 Июнь 2026
на канале: Robert James
96
1

In this Unity 2D Platformer tutorial, we learn how to access variables from other scripts.

As our project grows, we now have multiple ways to gain points and lose lives. Instead of creating separate score and life systems for every object, we'll learn how to reference existing scripts and update values from anywhere in our game.

You'll learn how to:

• Access variables from another script
• Understand public vs private variables
• Create script references
• Update score from multiple objects
• Update lives from multiple objects
• Connect enemy and player systems
• Use object references in Unity
• Share data between scripts
• Improve your existing score system
• Prepare for enemy movement systems

By the end of this lesson, your enemies, collectibles and hazards will all be able to update the same score and lives systems correctly.

#unity #unity2d #gamedevelopment #platformer #unitytutorial #learnunity #csharp #gamedev #indiedev #UnityScripts #programming #UnityCoding #ScriptCommunication #gameprogramming #unitybeginner