PickUp PreFabs
Last updated
Was this helpful?
Last updated
Was this helpful?
Throughout our game we will want to have game items for the player to interact with. Often these are considered Pick-up items.
In Unity, we'll want to create and configure gameObjects that will have this script attached to give desired behavior. You are required to have 4 types of PickUp objects in your game, 3 must have tag: Collectible, 1 can have tag: Hazard.
Create a 2D Sprite GameObject
Add a Collider2D to the GameObject, configure collider shape
Configure the Collider2D to be isTrigger == true
Select a tag for the gameObject: "Collectible", "Hazard", other?
Add Rigidbody2D if the gameObject will move
Optional add additional Collider2D inside trigger Collider2D, to keep this gameObject from falling through the floor's Collider2D.
Add PickUp script
Select type from dropdown in inspector
Set value, set a positive value
Drag into Project Assets Resource Folder to create as a prefab