当前位置:网站首页>[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
边栏推荐
- Pads export Gerber file
- 【论文笔记】Next-ViT: Next Generation Vision Transformer for Efficient Deployment in Realistic Industrial
- Configuring WAPI certificate security policy for Huawei wireless devices
- 《游戏机图鉴》:一份献给游戏玩家的回忆录
- [programmer 2 Civil Servant] III. resource collection
- Gather the wisdom of developers and consolidate the foundation of the database industry
- When providing digital talent services, Xi Zhi quickly opened its own digital school for each organization
- 数据提交类型 Request Payload 与 Form Data 的区别总结
- Introduction to cesium
- 【软件测试】包装简历从这几点出发、提升通过率
猜你喜欢

Problems during nanodet training: modulenotfounderror: no module named 'nanodet' solution

第一启富金怎么样

What if Oracle 19C migration encounters large lob tables?

SAP queries open Po (open purchase order)

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

Introduction to cesium

A domestic open source redis visualization tool that is super easy to use, with a high-value UI, which is really fragrant!!

【论文笔记】Next-ViT: Next Generation Vision Transformer for Efficient Deployment in Realistic Industrial

Beijing internal promotion | Microsoft STCA recruits nlp/ir/dl research interns (remote)

9 best engineering construction project management systems
随机推荐
Teach you to use cann to convert photos into cartoon style
Bingbing's learning notes: classes and objects (Part 1)
[pytorch] the most common function of view
做好项目管理的10个关键点和5大措施
[dynamic programming] - Knapsack model
第一启富金怎么样
[programmer 2 Civil Servant] IV. common problems
华为无线设备配置WPA2-802.1X-AES安全策略
js无法获取headers中Content-Disposition
【Unity入门计划】制作我的第一个小游戏
[notes] search rotation sort array
Kubernetes monitoring component metrics server deployment
paddlepaddle 34 调整模型的layer结构与forward流程(实现layer的增删改与forward的修改)
PADS导出gerber文件
Tips - prevent system problems and file loss
集群聊天服务器:项目问题汇总
Paper reading: UNET 3+: a full-scale connected UNET for medical image segmentation
关于GBase 自动关闭连接问题
[cloud native] the ribbon is no longer used at the bottom of openfeign, which started in 2020.0.x
What are runtimecompiler and runtimeonly