GeezerVison is showing github.com — When creating new Extended3D Objects I get a weird physics behavior · Issue #242 · enable3d/enable3d
When creating new Extended3D Objects I get a weird physics behavior #242
Description
When I create new objects during runtime, it seems like every 3d object will share the same rotation in simulation.
Why do they share the same physics body? Should they not be separate bodies for each new instance of Extended3D object?
I am using "this.physics.add.cylinder" in headless mode
Any help is appreciated - been stuck on it for days.
Example screenshot : https://ibb.co/GcBNCMv
As you can see all objects are rotating in real time with same rotation.... strange.
edit: Looks like I was using object.body.rotation and sending that to the client. It should be object.rotation instead for local rotation.
What is the difference between the two?
Activity
yandeu commented on Jan 28, 2022
Do you get the same error in Non-Headless mode?
Can you try to add a unique name to each object?
this.physics.add.cylinder({name:'unique'})
finkton1 commented on Jan 28, 2022
Do you get the same error in Non-Headless mode?
Can you try to add a unique name to each object? this.physics.add.cylinder({name:'unique'})
That does not seem to make a difference.
This same issue applies to body.position as well.
And no it does not seem to be an issue in non-headless mode.
yandeu commented on Jan 28, 2022
Are you calling transform and refresh on the body?
/** You have to call transform() before you can get or set the body's position or rotation. (for headless mode only) */
public transform() {
const t = this.physics.worldTransform
this.ammo.getMotionState().getWorldTransform(t)
}
/** You have to call refresh() after you set the position or rotation of the body. (for headless mode only) */
public refresh() {
const t = this.physics.worldTransform
this.ammo.getMotionState().setWorldTransform(t)
}finkton1 commented on Jan 28, 2022
Are you calling transform and refresh on the body?
/** You have to call transform() before you can get or set the body's position or rotation. (for headless mode only) */
public transform() {
const t = this.physics.worldTransform
this.ammo.getMotionState().getWorldTransform(t)
}
/** You have to call refresh() after you set the position or rotation of the body. (for headless mode only) */
public refresh() {
const t = this.physics.worldTransform
this.ammo.getMotionState().setWorldTransform(t)
}
Ahh - that was it, I was missing that.
I just added it to the server update loop, right before I send all the rotations and positions to the client.
Thanks for the help!!!
yandeu commented on Jan 29, 2022
github-actions commented on Nov 25, 2022
This issue is stale because it has been open 300 days with no activity. Remove stale label or comment or this will be closed in 10 days.
github-actions commented on Dec 5, 2022
This issue was closed because it has been stalled for 10 days with no activity.
Metadata
Metadata
Development
No branches or pull requestsIssue actions