Getting Familiar with Unity Playground Script
Tutorial
·
Beginner
·
+10XP
·
20 mins
·
(237)
Unity Technologies

Unity Playground comes with programmed scripts so that you just need to drag and drop the ones that you need on your hierarchy. Before we dive into game development, let's review Playground scripts that you can use to design your first game in Unity!
Languages available:
1. Movement Scripts
Unity Playground comes with pre-coded scripts so that you just need to drag and drop the ones that you need on your hierarchy. Before we dive in, make sure you look at all that’s available to work with!

Movement scripts allow you to move objects upon click of select keys or automatically.
- Open the Unity Playground Cheatsheet and look at the Movement pages (you can also just look on the right side).
- Look at what kinds of scripts are available.
Questions to Ask:
- What’s the difference between the scripts on ‘Movement’ and Movement 2’?
- Why would you want certain objects to move automatically and others to move upon pressing of keys?
- Why would you want to use ‘FollowTarget’, ‘Patrol’, and ’Wander’ for the enemy player?

2. Attributes Scripts

Attributes scripts allow you to move objects upon click of select keys or automatically.
- Bullet has no functionality of its own, but it holds a reference to which Player has shot the projectile
- Collectable awards a point to any player who touches the object
- DestroyForPoints destroys the GameObject on collision and awards points to the Player who originally shot the bullet
- HealthSystem allows characters, enemies, or objects to take damage, and potentially be removed from the game
- ModifyHealth makes any physical object capable of subtracting or adding health to any object that has theHealthSystem attribute
- Resource allows objects to be picked up and added to an inventory displayed by the UI
Definitions
- What is GameObject
3. Gameplay Scripts

Gameplay scripts are a miscellaneous category of scripts to produce gameplay effects. They act on their own, meaning they don’t require Conditions to activate them.
- ObjectCreatorArea generates new objects from a prefab, in a rectangular area
- ObjectShooter allows you to propel or shoot a prefab when pressing a key (by default Space)
- PickUpAndHold gives a character the ability to pick up (and drop) something
- TimeSelfDestruct gets rid of objects that are no longer needed in the scene after a certain time
Definitions
- What is a Prefab
4. Conditions Scripts

Conditions act as a gateway to other behaviors. If the condition is verified, then the attached Actions are executed.
- ConditionArea performs an action when a GameObject enters, exits, or stays inside the trigger collider
- ConditionCollision performs an action when this GameObject collides with another
- ConditionKeyPress performs an action when a button is pressed, released, or as long as it’s kept pressed
- ConditionRepeat performs an action repeatedly
Definitions
- What is a Trigger
- What is a Collider
5. Actions Scripts

Actions are executed when a Condition is verified.
- On/Off turns an object on or off
- Create creates a new GameObject from a Prefab in a specific position
- Destroy destroys a GameObject instantaneously on impact. Could be this object, or the one that suffered the impact
- Teleport teleports this or another object to a new location
- ConsumeResource (when a specified Type of Resource is present in the player’s inventory in the quantity specified in Amount Needed), the amount of resources is consumed
- DialogueBalloon creates a dialogue balloon on a character’s head
- LoadLevel restarts the level, or load another one (load another Unity scene)