Hello oot4chi, thank you for bringing this issue to our attention. The error you’re encountering indicates a potential issue with recursive object handling in the Rapier3D physics engine, which could be due to a stale reference or a circular reference when updating physics bodies.
To assist you better, let’s gather some more details and proceed with troubleshooting:
- Describe the Issue: Can you provide a brief description of what you are trying to achieve and how this error might be related to your intended functionality?
- Repro Steps: Have you been able to reproduce this error in a simplified scenario? If so, could you share the steps needed to reproduce the issue?
- Code Example: Do you have any code that triggers this error? If possible, sharing a snippet would be very helpful.
- GameObject Configuration: How are your GameObjects configured in Needle Engine? Specifically, are any GameObjects or components set up in a way that could cause a circular reference?
- Scene Layout: Is there a specific scene layout or structure that might be contributing to this issue?
- Network State: Are you using the networking features in Needle Engine? If so, how are you managing object state synchronization?
Regarding the specific error message:
- “Uncaught Error: recursive use of an object detected which would lead to unsafe aliasing in rust”:
- This suggests that there is an attempt to access a reference that is already being used within a recursive context or that there might be a circular reference in your objects’ states.
- Ensure that there are no circular references in the object hierarchy when setting up the physics bodies.
- Check if the
Rigidbody or Collider components are correctly instantiated and configured.
Troubleshooting Steps
-
Verify Prerequisites:
- Ensure you have followed the getting-started guidelines for Needle Engine 4.16 and Unity 6000.0.69f1.
-
Clean Installation:
- Run a clean installation by selecting your
Needle Engine component, holding Alt, and then clicking Clean Install.
-
Check Component Setup:
- Ensure that the
Rigidbody and Collider components are correctly initialized and there are no circular dependencies in their setup.
-
Scene Structure:
- Check the scene for any complex structures or interactions that might be causing the issue. This includes checking the hierarchy for any duplicate or interdependent object references.
-
Update Physics Components:
- Verify that the
GryncPhysicsBody function is properly configured and called only when necessary. Ensure that the GameObject’s state is correctly managed during updates.
Simplified Example
Here is a simplified example to help you understand how to properly set up physics components:
import { Behaviour, Rigidbody, Collider } from "@needle-tools/engine";
export class PhysicsExample extends Behaviour {
start() {
// Ensure the GameObject has no existing Rigidbody or Collider
const rb = this.gameObject.addNewComponent(Rigidbody);
rb.mass = 10;
rb.drag = 0.5;
rb.angularDrag = 0.5;
// Ensure the Collider is added to the exact same GameObject, not to a child or parent.
const collider = this.gameObject.addNewComponent(Collider);
collider.shape = "box"; // or "sphere", "capsule", etc.
collider.size = [2, 2, 2]; // or appropriate size for your shape
console.log("Physics enabled!");
console.log("Rigidbody:", rb);
console.log("Collider:", collider);
}
}
Additional Resources
If you can provide more details based on the above questions, I can help you more specifically resolve the issue.
Sources: Needle Engine API (67%), Needle Engine API (61%), Needle Engine API (59%), Needle Engine API (59%), Needle Engine API (57%), Needle Engine Docs (57%), Needle Engine API (56%), Needle Engine Docs (55%), Needle Engine Docs (55%)
1 replies left - Become PRO for more replies.
Reply to this post directly if you need further help (bottom right button)