unity physics bug
This happens because a Rigidbody is being added to a GO with zero scale. Zero scale collider means there wont' be a well defined inertia tensor, which is essential for dynamics actually. There are warnings printed in the console.
当前游戏内用了对象池缓存物理对象,但物理对象有mesh动画,动画结束 gameobject scale = 0;
当对象回池的状态,scale = 0, active = false, 并设置物理一些参数。
当从对象池取出的 scale = 0, active = true,
scale = 1
fixupdate first time postion ok
fixupdate second time position nan
update position nan.
- 建议解决方案,动画 最后scale = 0.01。
- 回池的时候 scale 置为 1.
https://forum.unity.com/threads/intermittent-infinity-or-nan-floating-point-numbers.1444306/
pc 运行良好,iphone 和 android failed.
当此对象 position nan 之后, physics.raycast 拾取不到正常的对象。
1 为解决问题的根本。 2. 是临时解决方法。
unity 2021.3.*