Add Interaction System to Your Unity 2D Game 🎮

Learn to add object interactions like opening chests that spawn items in your Unity 2D game. Step-by-step guide included!

Add Interaction System to Your Unity 2D Game 🎮
Game Code Library
15.5K views • Feb 5, 2025
Add Interaction System to Your Unity 2D Game 🎮

About this video

Let's add interacting with in game objects of any type to our game! We'll add opening chests as our interactable object example, which will spawn an item and stay opened after saving our game. We'll use a collider to trigger when interactable objects are in game, then use Unity's Input System to know when our player has pressed the interact button!

You can follow the full playlist 🐸 to complete the full top down base template
Full Playlist: https://www.youtube.com/playlist?list=PLaaFfzxy_80HtVvBnpK_IjSC8_Y9AOhuP

Get the code: https://www.patreon.com/posts/add-interactions-121505137
Download the Top Down Template🐸: https://gamecodelibrary.itch.io/top-down-2d-base-template

Sprite sheet: https://pixel-boy.itch.io/ninja-adventure-asset-pack

All source code for all videos I have made and will make in the future can be found on my Patreon:
https://www.patreon.com/GameCodeLibrary

Be sure to subscribe to see what kind of adventure we can go on together! I'm excited! :-)

If you have any suggestions, feedback or questions, be sure to comment below! Any opinions will help me out on this journey ♡

Check out the full platformer playlist!
https://www.youtube.com/playlist?list=PLaaFfzxy_80EWnrTHyUkkIy6mJrhwGYN0

BUY THE COMPLETE PLATFORMER GAME TEMPLATE NOW!!!
https://gamecodelibrary.itch.io/2d-platformer-template
https://www.patreon.com/GameCodeLibrary/shop

#unity #gamedev #gamedevelopment #unity2d #topdown

0:00 - Intro
0:39 - Chest GameObject
2:00 - Interactable Interface
3:06 - Chest Script
4:51 - Global Helper
6:03 - Chest Script
8:54 - Interaction Detector
10:19 - Interaction Detector Script
13:21 - Interaction Detector Setup
13:30 - Chest Setup
14:04 - Interaction Input
15:25 - Working Test - Open Chest
15:55 - SaveData Script
16:48 - SaveController Script
20:10 - Working Test - with Save!
20:36 - Delete Save Data
21:12 - Broken Inventory Fix
22:41 - Icon Disappear Fix
23:16 - FINAL Test!
23:37 - Get the Code
23:58 - Next Video
24:10 - Outro

Tags and Topics

Browse our collection to discover more content in these categories.

Video Information

Views

15.5K

Likes

378

Duration

24:19

Published

Feb 5, 2025

User Reviews

4.6
(3)
Rate:

Related Trending Topics

LIVE TRENDS

Related trending topics. Click any trend to explore more videos.