Prototype for DETECTING OBJECTS entering a COLLIDER in Unity

Introduction

I made a simple prototype for Unity to show how to detect when an object enters a collider defined by another object and execute functions in that case.

DOWNLOAD THE UNITY PACKAGE HERE

Scene of the prototype that comes in the Unity Package

The explanation was divided into two parts, the first part deals with the necessary settings for the objects in the scene and the components to be added in the inspector. The second part is about programming, what functions objects call when they detect other objects through their collider.

Here you have the two videos:

🟒 OBJECT DETECTION PART 1

Setup all the GameObjects and components in the Unity Editor in order to configure colliders to detect another colliders.

🟒 OBJECT DETECTION PART 2

Analyze the functions from the Script that are called when a collider enters another collider mark as trigger.

Implementation

The main goal of this video is to help you understand how Unity’s collider detection system works, this will allow you to take better advantage of it according to your needs.

Most of the actions that occur in this prototype consist simply in activating and deactivating GameObjects of the scene and also components, for example the “enemy” that falls from the sky when we pass through a certain area is simply a GameObject that was inactive and we activate it at the moment we detect that the player enters the collider.

Here are two videos that explain how to activate and deactivate GameObjects from the scene and how to activate and deactivate components attached to GameObjects from the scene.

ACTIVATE and DEACTIVATE GameObjects through code
🟒
ACTIVATE and DEACTIVATE Components through code
PART 2

🟒

🎁 1000 SUBS GIVE AWAY 🎁

☝️

WHEN THIS CHANNEL REACHES 1000 SUBSCRIBERS

THE SOURCE CODE OF THESE UNITY PROJECTS WILL BE AVAILABLE FOR DOWNLOAD HERE

...

πŸ”₯ CLICK HERE TO SUBSCRIBE πŸ”₯

Package to download:

Below you can download the Unity package that when imported into your engine, you will recover the Assets we use and you will be able to test it on your own computer.

Prototype: Object Detection and Trigger Events in Unity

🎁 1000 SUBS GIVE AWAY 🎁

I BRIEFLY INTERRUPT YOUR DOWNLOAD TO INFORM THE FOLLOWING

When the channel reaches 1000 subscribers, the SOURCE CODE of the following TWO COMPLETE UNITY PROJECTS (the INVADERS prototype and MAZE prototype) will be available for download. That means all the necessary assets so you can import them into your own project and compile them.

CLICK HERE TO SUBSCRIBE!


Secured By miniOrange