MissingComponentException: There is no 'Rigidbody2D' attached to the "remove.photos-removed-background" game object, but a script is trying to access it. You probably need to add a Rigidbody2D to the game object "remove.photos-removed-background". Or your script needs to check if the component is attached before using it. UnityEngine.Rigidbody2D.AddForce (UnityEngine.Vector2 force, UnityEngine.ForceMode2D mode) (at <bc1b7332dc1d4a95adb4de1b36af4735>:0) UnityEngine.Rigidbody2D.AddForce (UnityEngine.Vector2 force) (at <bc1b7332dc1d4a95adb4de1b36af4735>:0)
时间: 2023-06-20 08:06:40 浏览: 1208
这个错误提示是因为在某个脚本中,尝试访问了 "remove.photos-removed-background" 游戏对象上的 Rigidbody2D 组件,但是该游戏对象上并没有添加 Rigidbody2D 组件。
要解决这个问题,你需要在 "remove.photos-removed-background" 游戏对象上添加 Rigidbody2D 组件。你可以在 Unity 编辑器中选中该游戏对象,然后点击菜单栏上的 "Component",再选择 "Physics 2D",最后点击 "Rigidbody 2D"。这样就可以为该游戏对象添加 Rigidbody2D 组件了。
如果你已经添加了 Rigidbody2D 组件,但是仍然出现这个错误提示,那么需要检查一下你的脚本是否正确地引用了该组件。你可以在脚本中使用 GetComponent<Rigidbody2D>() 方法来获取 Rigidbody2D 组件,并在使用它之前进行 null 判断。
相关问题
Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported since Unity 5. If you want to use a non-convex mesh either make the Rigidbody kinematic or remove the Rigidbody component. Scene hierarchy path "砂轮", Mesh asset path "Library/unity default resources" Mesh name "Cylinder"
这是一个关于Unity游戏引擎的错误提示。提示意思是在Unity 5之后,非凸的MeshCollider与非动力学的Rigidbody不再受支持。如果要使用非凸的MeshCollider,可以将Rigidbody设置为动力学,或者删除Rigidbody组件。在错误提示中给出了出错物体的名称为“砂轮”,Mesh资源路径为“Library/unity default resources”,Mesh名称为“Cylinder”。你需要检查这个物体的Collider和Rigidbody设置以解决这个错误。
Non-convex MeshCollider with non-kinematic Rigidbody is no longer supported in Unity 5. If you want to use a non-convex mesh either make the Rigidbody kinematic or remove the Rigidbody component. Scene hierarchy path "Cube (1)", Mesh asset path "Library/unity default resources" Mesh name "Cube"
在Unity 5中,不再支持非运动刚体(non-kinematic Rigidbody)与非凸网格碰撞器(non-convex MeshCollider)的组合。如果你想使用非凸网格,你可以将刚体设为运动刚体(kinematic Rigidbody),或者移除刚体组件。在场景层级路径 "Cube (1)",网格资源路径 "Library/unity default resources",网格名称 "Cube"。
阅读全文