mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:49:24 +02:00
Fix to pistol.js so muzzle flash particle system doesn't stick around forever
This commit is contained in:
parent
5b177404d5
commit
4360595ed6
1 changed files with 27 additions and 41 deletions
|
@ -37,6 +37,13 @@
|
||||||
this.bulletForce = 10;
|
this.bulletForce = 10;
|
||||||
this.showLaser = false;
|
this.showLaser = false;
|
||||||
|
|
||||||
|
this.laserOffsets = {
|
||||||
|
y: 0.095
|
||||||
|
};
|
||||||
|
this.firingOffsets = {
|
||||||
|
z: 0.16
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Pistol.prototype = {
|
Pistol.prototype = {
|
||||||
|
@ -272,46 +279,12 @@
|
||||||
});
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
Entities.editEntity(this.flash, {
|
var flash = Entities.addEntity({
|
||||||
isEmitting: true
|
|
||||||
});
|
|
||||||
Script.setTimeout(function() {
|
|
||||||
Entities.editEntity(_this.flash, {
|
|
||||||
isEmitting: false
|
|
||||||
});
|
|
||||||
}, 100)
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
preload: function(entityID) {
|
|
||||||
this.entityID = entityID;
|
|
||||||
this.laser = Overlays.addOverlay("line3d", {
|
|
||||||
start: ZERO_VECTOR,
|
|
||||||
end: ZERO_VECTOR,
|
|
||||||
color: COLORS.RED,
|
|
||||||
alpha: 1,
|
|
||||||
visible: true,
|
|
||||||
lineWidth: 2
|
|
||||||
});
|
|
||||||
this.laserOffsets = {
|
|
||||||
y: 0.095
|
|
||||||
};
|
|
||||||
this.firingOffsets = {
|
|
||||||
z: 0.16
|
|
||||||
}
|
|
||||||
var gunProps = Entities.getEntityProperties(this.entityID, ['position', 'rotation']);
|
|
||||||
var position = gunProps.position;
|
|
||||||
var rotation = Quat.fromPitchYawRollDegrees(0, 0, 0);
|
|
||||||
this.firingDirection = Quat.getFront(rotation);
|
|
||||||
var upVec = Quat.getUp(rotation);
|
|
||||||
this.barrelPoint = Vec3.sum(position, Vec3.multiply(upVec, this.laserOffsets.y));
|
|
||||||
this.barrelPoint = Vec3.sum(this.barrelPoint, Vec3.multiply(this.firingDirection, this.firingOffsets.z))
|
|
||||||
|
|
||||||
this.flash = Entities.addEntity({
|
|
||||||
type: "ParticleEffect",
|
type: "ParticleEffect",
|
||||||
position: this.barrelPoint,
|
position: this.barrelPoint,
|
||||||
"name": "Muzzle Flash",
|
"name": "Muzzle Flash",
|
||||||
isEmitting: false,
|
lifetime: 4,
|
||||||
|
parentID: this.entityID,
|
||||||
"color": {
|
"color": {
|
||||||
red: 228,
|
red: 228,
|
||||||
green: 128,
|
green: 128,
|
||||||
|
@ -363,14 +336,27 @@
|
||||||
"additiveBlending": true,
|
"additiveBlending": true,
|
||||||
"textures": "http://ericrius1.github.io/PartiArt/assets/star.png"
|
"textures": "http://ericrius1.github.io/PartiArt/assets/star.png"
|
||||||
});
|
});
|
||||||
|
Script.setTimeout(function() {
|
||||||
|
Entities.editEntity(flash, {
|
||||||
|
isEmitting: false
|
||||||
|
});
|
||||||
|
}, 100)
|
||||||
|
|
||||||
Script.setTimeout(function() {
|
},
|
||||||
Entities.editEntity(_this.flash, {parentID: _this.entityID});
|
|
||||||
}, 500)
|
|
||||||
|
|
||||||
|
preload: function(entityID) {
|
||||||
|
this.entityID = entityID;
|
||||||
|
this.laser = Overlays.addOverlay("line3d", {
|
||||||
|
start: ZERO_VECTOR,
|
||||||
|
end: ZERO_VECTOR,
|
||||||
|
color: COLORS.RED,
|
||||||
|
alpha: 1,
|
||||||
|
visible: true,
|
||||||
|
lineWidth: 2
|
||||||
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// entity scripts always need to return a newly constructed object of our type
|
// entity scripts always need to return a newly constructed object of our type
|
||||||
return new Pistol();
|
return new Pistol();
|
||||||
});
|
});
|
Loading…
Reference in a new issue