Skip to content

Commit

Permalink
Check if entity has networked component before taking ownership
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Sep 14, 2023
1 parent 49bed63 commit c34178c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/systems/bit-constraints-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
ConstraintHandLeft,
ConstraintHandRight,
ConstraintRemoteLeft,
ConstraintRemoteRight
ConstraintRemoteRight,
Networked
} from "../bit-components";
import { takeOwnership } from "../utils/take-ownership";

Expand All @@ -45,7 +46,9 @@ const releaseBodyOptions = { activationState: ACTIVE_TAG };
function add(world, physicsSystem, interactor, constraintComponent, entities) {
for (let i = 0; i < entities.length; i++) {
const eid = findAncestorEntity(world, entities[i], ancestor => hasComponent(world, Rigidbody, ancestor));
takeOwnership(world, eid);
if (hasComponent(world, Networked, eid)) {
takeOwnership(world, eid);
}
physicsSystem.updateRigidBodyOptions(eid, grabBodyOptions);
physicsSystem.addConstraint(interactor, Rigidbody.bodyId[eid], Rigidbody.bodyId[interactor], {});
addComponent(world, Constraint, eid);
Expand Down

0 comments on commit c34178c

Please sign in to comment.