当前位置:网站首页>[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
边栏推荐
- Delete in elasticserach_ by_ What is the mechanism of query?
- Million level element optimization: real-time vector tile service based on PG and PostGIS
- What are runtimecompiler and runtimeonly
- A fast method of data set enhancement for deep learning
- 从ACL 2022 Onsite经历看NLP热点
- 【论文笔记】Progressive Layered Extraction (PLE): A Novel Multi-Task Learning (MTL) Model for Personalized
- Luo min from qudian, prefabricate "leeks"?
- RPC communication principle and project technology selection
- 【程序员2公务员】关于体制调研的一些常见问题总结
- The idea of the regular crawler of the scratch
猜你喜欢
随机推荐
3. Promise
【Unity入门计划】基本概念-2D碰撞体Collider 2D
LeetCode118. 杨辉三角
When importing data in batches, you always prompt "failure reason: SQL parsing failure: parsing file failure:: null". What's the matter?
Quickly build a centralized logging platform through elk
J1 common DOS commands (P25)
Leetcode118. Yanghui triangle
First, how about qifujin
北京内推 | 微软STCA招聘NLP/IR/DL方向研究型实习生(可远程)
Robot framework mobile terminal Automation Test ----- 01 environment installation
Analysis of difficulties in diagramscene project
Teach you to use cann to convert photos into cartoon style
DJI内推码(一码一用,限时内推)
Summary of learning notes of deep learning application development (II)
第一启富金怎么样
New functions of shixizhi are online. These new functions are online in June. Can you use them?
Design of workflow system
用VS Code搞Qt6:编译源代码与基本配置
SAP queries open Po (open purchase order)
diagramscene工程难点分析









![[dynamic programming] - Knapsack model](/img/0d/c467e70457495f130ec217660cbea7.png)