3d的单向平台检测
https://www.youtube.com/watch?v=qwwjwb7XlUc
using UnityEngine; [RequireComponent(typeof(BoxCollider))]
public class OneWayBoxCollider : MonoBehaviour
{
/// <summary> The direction that the other object should be coming from for entry. </summary>
[SerializeField] private Vector3 entryDirection = Vector3.up;
/// <summary> Should the entry direction be used as a local direction? </summary>
[SerializeField] private bool localDirection = false;
/// <summary> How large should the trigger be in comparison to the original collider? </summary>
[SerializeField] private Vector3 triggerScale = Vector3.one * 1.25f;
/// <summary> The original collider. Will always be present thanks to the RequireComponent attribute. </summary>
private new BoxCollider collider = null;
/// <summary> The trigger that we add ourselves once the game starts up. </summary>
private BoxCollider collisionCheckTrigger = null; /// <summary> The entry direction, calculated accordingly based on whether it is a local direction or not.
/// This is pretty much what I've done in the video when copy-pasting the local direction check, but written as a property. </summary>
public Vector3 Direction => localDirection ? transform.TransformDirection(entryDirection.normalized) : entryDirection.normalized; private void Awake()
{
collider = GetComponent<BoxCollider>(); // Adding the BoxCollider and making sure that its sizes match the ones
// of the OG collider.
collisionCheckTrigger = gameObject.AddComponent<BoxCollider>();
collisionCheckTrigger.size = new Vector3(
collider.size.x * triggerScale.x,
collider.size.y * triggerScale.y,
collider.size.z * triggerScale.z
);
collisionCheckTrigger.center = collider.center;
collisionCheckTrigger.isTrigger = true;
} private void OnValidate()
{
// This bit of code exists only to prevent OnDrawGizmos from throwing
// errors in the editor mode when it does not have reference to the
// collider, if used.
collider = GetComponent<BoxCollider>();
collider.isTrigger = false;
} private void OnTriggerStay(Collider other)
{
// Simulate a collision between our trigger and the intruder to check
// the direction that the latter is coming from. The method returns true
// if any collision has been detected.
if (Physics.ComputePenetration(
collisionCheckTrigger, transform.position, transform.rotation,
other, other.transform.position, other.transform.rotation,
out Vector3 collisionDirection, out float _))
{
float dot = Vector3.Dot(Direction, collisionDirection); // Opposite direction; passing not allowed.
if (dot < 0)
{
// Making sure that the two object are NOT ignoring each other.
Physics.IgnoreCollision(collider, other, false);
}
else
{
// Making the colliders ignore each other, and thus allow passage
// from one way.
Physics.IgnoreCollision(collider, other, true);
}
}
} private void OnDrawGizmosSelected()
{
// Instead of directly using the transform.position, we're using the
// collider center, converted into global position. The way I did it
// in the video made it easier to write, but the on-screen drawing would
// not take in consideration the actual offset of the collider.
Gizmos.color = Color.red;
Gizmos.DrawRay(transform.TransformPoint(collider.center), Direction * 2); Gizmos.color = Color.green;
Gizmos.DrawRay(transform.TransformPoint(collider.center), -Direction * 2);
}
}
3d的单向平台检测的更多相关文章
- 教你用Ossim平台检测网络的Shellcode攻击
教你用Ossim平台检测网络的Shellcode攻击行为 教程: http://www.tudou.com/programs/view/-hxTm0q1tDY/ 以下是视频截图: 更多视频内容: 本文 ...
- JT796、JT1077部标平台检测报名须知
检测报名须知 申请道路运输车辆卫星定位系统平台标准符合性检测时,请先将1检测意向单(只针对企业监控平台).2符合性检测申请材料(基本材料包括:申请函.授权人身份证复印件.检测登记表.运输企业信息表.平 ...
- JT796、JT808、JT809、JT1076、JT1077、JT1078部标平台过检道路运输车辆卫星定位系统企业视频监控平台检测登记表
道路运输车辆卫星定位系统企业视频监控平台检测登记表的具体格式如下: 报名检测需要以下材料: 0检测报名须知.doc 点击下载 1检测意向单.doc 点击下载 2-1道路运输车辆卫星定位系统企业 ...
- PointRCNN: 点云的3D目标生成与检测
PointRCNN: 点云的3D目标生成与检测 PointRCNN: 3D Object Proposal Generation and Detection from Point Cloud 论文地址 ...
- AssetBundle系列——打包前进行平台检测
在生成AssetBundle的时候,如果目标平台和当前平台不一致,Unity3D会自动将当前平台转换为目标平台. 如果项目中资源量比较大,这个转换过程是相当漫长的,并且不能够强行中止. 所以最好在Bu ...
- 【3D】PoseCNN姿态检测网络复现过程记录
最近在研究室内6D姿态检测相关问题,计划在PoseCNN网络基础上进行改进实现.但是在第一步的复现过程中踩了无数的坑,最终成功运行了demo,但目前数据集train还是遇到了一些问题.有问题欢迎一起交 ...
- 嵌入式 hi3518平台检测网线是否插上
/********************************** (C) COPYRIGHT ******************************* * File Name ...
- JT/T 1077-2016《道路运输车辆卫星定位系统车载视频平台技术要求》平台标准符合性检测合同
合同编号: 道路运输车辆卫星定位系统 平台标准符合性检测合同 委托方(甲方): 受托方(乙方): 交通运输通信信息工程质量检测中心 签订时间: 签订地点: 北京市 委托方(甲方): 委托方(甲方): ...
- GB∕T 35658平台过检 已通过最新的部标JT/T 808-2019, JT/T 809-2019标准检测
2019年交通部GPS平台检测标准发生了重大变化, 原来的796平台功能标准, 变更为GB/T35658标准, 这个标准其实2017年就公布了, 实际上还是796标准, 但是检测项目,以前是可选的, ...
- STP-17-对抗单向链路问题
单向链路问题是指链路上的两条传输路径中,有一条出现了问题,但并不是两条同时出现问题.这可能是因为线缆错误.切断了一条光纤线缆.拔掉了一根管线.GBIC问题,或其他问题.因为STP会监控入向BPDU,以 ...
随机推荐
- 【记录】IDA|IDA设置text view为默认,并解决IDA7.6打开新固件卡顿的问题
版本:IDA Pro 7.6 Graph View(控制流视图)其实我真的看得很少,因为遇到分析难题时总是是因为间接调用,它根本分析不出来.但是一开IDA它就自动分析这个特别卡.所以今天想彻底解决一下 ...
- 【记录】Linux|服务器一些常用指令
文章目录 1 查看显卡 2 解决存储空间不足 3 挂载和卸载磁盘 4 安装conda虚拟环境 5 后台运行程序 方法1:使用nohup 方法2:使用screen 6 PyCharm专业版远程连接服务器 ...
- 【HUST】网安|操作系统实验|实验四 设备管理、文件管理
文章目录 任务 任务1 编写一个Linux内核模块,并完成安装/卸载等操作. 1. 提示 2. 任务代码 3. 结果及说明 任务2 编写Linux驱动程序并编程应用程序测试. 1. 提示 2. 任务代 ...
- IDEA问题之“调整IDEA字体大小”
调整IDEA字体大小 1.正常版 2. 远程版
- lovelymem梭哈solar内存取证---Alex4nd3r
内存取证1 请找到rdp连接的跳板地址 flag{192.168.60.220} 内存取证2 请找到攻击者下载黑客工具的IP地址 控制台信息 flag{155.94.204.67} 内存取证3 攻击者 ...
- python3验证手机号码
import redef check_phone_right(self, phone_number): """检测号码是否正确""" pho ...
- Qt 的一个大坑:visual studio中setStyleSheet不支持jpg
在代码中设置QWidget的背景图,一般会使用setStyleSeeht函数去设置样式表: border-image:("c:x.png"); 这里有个大坑:不支持jpg图片!
- 「Log」做题记录 2024.1.29-
\(2024.1.29-2024.2.4\) \(\color{royalblue}{P5903}\) 树上 \(k\) 级祖先模板,长链剖分. \(\color{blueviolet}{CF1009 ...
- 聊一聊 Linux 上对函数进行 hook 的两种方式
一:背景 1. 讲故事 前两篇我们介绍了 Minhook 在 Windows 平台上的强大功效,这一篇我们来聊一聊如何在 Linux 上对函数进行hook,这里介绍两种方式. 轻量级的 LD_PREL ...
- 部分请求报 CROS ERROR
当我在写系统时,发现/post/list请求报错跨域问题.但是/login,logout请求能通过.报错为下: 于是开始找文档,最开始以为是后端跨域配置导致的(但是仔细一想,发现/login又能够通过 ...