当前位置:网站首页>[unity entry program] basic concept trigger
[unity entry program] basic concept trigger
2022-07-25 07:33:00 【flashinggg】
Catalog
Conditions for collision detection
The relationship between trigger and collision body
Of a collision body Is Trigger Options
Trigger the condition of detection implementation
Reference resources
Unity3D Basics 15: trigger _Jaihk662 The blog of
Triggers modular - Unity manual
Collider detection and trigger detection - Simple books (jianshu.com)
You will have a choice when adding collider components “ Whether it is a trigger ”——Is Trigger The option to , Check this box , When the rigid body moves, it will pass through the collision body .

Before understanding triggers , You can learn what is a trigger event .
Triggering event
- Triggering event —— When a GameObject bound to a collider enters the trigger range of another GameObject
- When the trigger event occurs , There will be no direct collision , It is —— As long as you enter the trigger area, you will perform some operations
Trigger and collider
Collision detection
Unity Middle collision body Coliider It is a kind of component , There are many kinds .
Collision detection 3 Methods
- When the colliders of two game objects first touch ( Note that this is not a game object contact , It's the collider of the game object Collider Component contact ), Call once OnCollisionEnter() function
- As long as the two colliders are in contact , Will always call OnCollisionStay() function
- When two colliding bodies separate from each other , Call once OnCollisionExit() function
Conditions for collision detection
Two game objects A and B Achieve collision detection
- The moving object must be a rigid body ,A and B At least one is a rigid body
- A and B They must all be collision bodies (Is Trigger All must be closed , It cannot be a trigger )
- A and B You can detect collisions with each other ( There is a collision detection script)
The relationship between trigger and collision body
- stay Unity in , There are two ways to detect collisions : Use triggers to detect & Use collision detection
- The collider can be regarded as the carrier of the trigger , The trigger is just an attribute of the collision body
Trigger detection
Of a collision body Is Trigger Options
After checking , The collision body becomes a trigger , At this time, the boundary of the collision body becomes the trigger area .

When the trigger event occurs , Rigid bodies do not collide directly with colliding objects , But directly penetrate the collision body .
Trigger detection 3 Methods
- If the impactor component is checked Is Trigger The option to , When the trigger event occurs OnTriggerEnter(Collier) function
- When still within the trigger range , Would call OnTriggerStay(Collier) function
- When leaving the trigger range , Trigger will be called OnTriggerExit(Collier) function
Trigger the condition of detection implementation
When A and B Two objects implement trigger detection
- The moving object must be a rigid body
- A and B As long as one is a trigger , Trigger detection can be realized
- A and B Trigger detection can be realized with each other ( There is a trigger for detection script)
Trigger application scenario
When we want to detect contact between objects , We don't want collision detection to affect the movement of objects , Trigger can be used at this time , For example, the following situations are suitable for using triggers
- Detect whether the object passes through an area on the map
- When people are close to the door, the door opens automatically
边栏推荐
- [programmer 2 Civil Servant] I. Basic Knowledge
- DJI push code (one code for one use, limited time push)
- Line generation (matrix ')
- Summary of learning notes of deep learning application development (II)
- Flinkcdc2.0 uses flinksql to collect MySQL
- 纳米数据足球数据,足球赛事比分,体育数据api,卡塔尔世界杯
- LeetCode118. 杨辉三角
- 全新8.6版本SEO快排系统(可源码级搭建)
- 【ES6】函数的参数、Symbol数据类型、迭代器与生成器
- Gan series of confrontation generation network -- Gan principle and small case of handwritten digit generation
猜你喜欢

Use cyclegan to train self-made data sets, popular tutorials, and get started quickly

Leetcode118. Yanghui triangle

BOM overview

第一启富金怎么样

【Unity入门计划】基本概念-触发器 Trigger
![[dynamic programming] - Knapsack model](/img/0d/c467e70457495f130ec217660cbea7.png)
[dynamic programming] - Knapsack model

12 combination methods and risk interpretation of database architecture optimization (books available)

"Game illustrated book": a memoir dedicated to game players

如何在KVM环境中使用网络安装部署多台虚拟服务器

Line generation (matrix ')
随机推荐
Kubernetes monitoring component metrics server deployment
RPC communication principle and project technology selection
Pads export Gerber file
【刷题笔记】搜索旋转排序数组
Room database migration
About gbase automatically closing the connection
Luo min from qudian, prefabricate "leeks"?
Bingbing's learning notes: classes and objects (Part 1)
cesium简介
Ask the bosses: MySQL CDC stores configuration data, and Kafka has history
QT6 with vs Code: compiling source code and basic configuration
Matlab self programming series (1) -- angular distribution function
Million level element optimization: real-time vector tile service based on PG and PostGIS
JS note 17: the whole process of jest project configuration of typescript project
Tips - prevent system problems and file loss
Have you got the advanced usage of pytest?
Analysis of difficulties in diagramscene project
Completely replace the redis+ database architecture, and JD 618 is stable!
[programmer 2 Civil Servant] summary of some common problems about system research
轮询、中断、DMA和通道