SceneKit SCNPhysicsBody 得到休息通知 [英] SceneKit SCNPhysicsBody get notified of resting

查看:66
本文介绍了SceneKit SCNPhysicsBody 得到休息通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SceneKitdynamicBody 处于静止状态时,有没有办法得到通知?当 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?.

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

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 得到休息通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆