Skip to content
Snippets Groups Projects
Commit ce177ce9 authored by Kevin Lee's avatar Kevin Lee
Browse files

need to use CANNON.Vec3's; also check ownership

parent abd59108
No related branches found
No related tags found
No related merge requests found
/* global CANNON */
AFRAME.registerComponent("duck", {
schema: {
initialForce: { default: 0 },
......@@ -8,8 +9,8 @@ AFRAME.registerComponent("duck", {
init: function() {
this.physicsSystem = this.el.sceneEl.systems.physics;
this.hasBody = false;
this.position = new THREE.Vector3();
this.force = new THREE.Vector3(0, this.data.initialForce, 0);
this.position = new CANNON.Vec3();
this.force = new CANNON.Vec3(0, this.data.initialForce, 0);
this.initialScale = this.el.object3D.scale.x;
this.maxScale = this.data.maxScale * this.initialScale;
},
......@@ -23,7 +24,7 @@ AFRAME.registerComponent("duck", {
},
beforeStep: function() {
if (this.el.body) {
if (this.el.body && NAF.utils.isMine(this.el)) {
const currentScale = this.el.object3D.scale.x;
const ratio = Math.min(1, (currentScale - this.initialScale) / (this.maxScale - this.initialScale));
const force = ratio * this.data.maxForce;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment