SceneKit SCNPhysicsBody 得到休息通知

编程入门 行业动态 更新时间:2024-10-27 22:30:23
本文介绍了SceneKit SCNPhysicsBody 得到休息通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

SceneKit当 dynamicBody 处于静止状态时,有没有办法得到通知?当 dynamicBody 落到地面并完全停止移动时,我想删除它 - 我认为我会有相当多的那些,所以我想使用基于事件的东西而不是遍历所有body 并检查它们的速度?

SceneKit Is there a way to get notified when dynamicBody is in resting State ? I want to remove dynamicBody when it finished to fall to the ground and stopped moving completely - I presume that I will have quite large amount of those so I would like to use something event based rather than looping through all the bodies and checking their velocities ?

推荐答案

您可以对 isResting 属性使用键值观察.请参阅 Swift 中是否提供键值观察 (KVO)?.

You could use Key-Value Observation on the isResting property. See Is key-value observation (KVO) available in Swift?.

或者您可以使用 SCNPhysicsContact 和 SCNPhysicsContactDelegate 来检测与地板的碰撞,并使用它来触发速度检查.

Or you could use the SCNPhysicsContact and SCNPhysicsContactDelegate to detect collisions with the floor, and use that to trigger a check for velocity.

更多推荐

SceneKit SCNPhysicsBody 得到休息通知

本文发布于:2023-06-04 21:17:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/505235.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通知   SceneKit   SCNPhysicsBody

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!