mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 02:31:13 +02:00
shootable
This commit is contained in:
parent
281d058a24
commit
6f994d6274
2 changed files with 19 additions and 19 deletions
|
@ -76,6 +76,7 @@ var barrelVectors = [0, 0];
|
||||||
var barrelTips = [0, 0];
|
var barrelTips = [0, 0];
|
||||||
|
|
||||||
|
|
||||||
|
// If enabled, anything can be shot, otherwise, an entity needs to have "isShootable" set in its userData
|
||||||
var shootAnything = true;
|
var shootAnything = true;
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,7 +107,6 @@ function update(deltaTime) {
|
||||||
alpha: 1,
|
alpha: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ var kickback = function(animationProperties) {
|
||||||
|
|
||||||
|
|
||||||
function fire(side, value) {
|
function fire(side, value) {
|
||||||
if(value == 0) {
|
if (value == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Audio.playSound(fireSound, {
|
Audio.playSound(fireSound, {
|
||||||
|
@ -156,24 +156,23 @@ function fire(side, value) {
|
||||||
|
|
||||||
var intersection = Entities.findRayIntersection(pickRay, true);
|
var intersection = Entities.findRayIntersection(pickRay, true);
|
||||||
if (intersection.intersects) {
|
if (intersection.intersects) {
|
||||||
if (intersection.properties.name === "rat") {
|
|
||||||
var forceDirection = JSON.stringify({
|
Script.setTimeout(function() {
|
||||||
forceDirection: shotDirection
|
if (shootAnything && intersection.properties.collisionsWillMove === true) {
|
||||||
});
|
// Any entity with collisions will move can be shot
|
||||||
Entities.callEntityMethod(intersection.entityID, 'onHit', [forceDirection]);
|
Entities.editEntity(intersection.entityID, {
|
||||||
} else {
|
velocity: Vec3.multiply(shotDirection, GUN_FORCE)
|
||||||
Script.setTimeout(function() {
|
});
|
||||||
if (shootAnything) {
|
createEntityHitEffect(intersection.intersection);
|
||||||
Entities.editEntity(intersection.entityID, {
|
} else {
|
||||||
velocity: Vec3.multiply(shotDirection, GUN_FORCE)
|
|
||||||
});
|
}
|
||||||
}
|
}, 50);
|
||||||
createWallHit(intersection.intersection);
|
|
||||||
}, 50);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function
|
||||||
|
|
||||||
|
|
||||||
function scriptEnding() {
|
function scriptEnding() {
|
||||||
|
@ -209,7 +208,7 @@ Script.scriptEnding.connect(scriptEnding);
|
||||||
Script.update.connect(update);
|
Script.update.connect(update);
|
||||||
|
|
||||||
|
|
||||||
function createWallHit(position) {
|
function createEntityHitEffect(position) {
|
||||||
var flash = Entities.addEntity({
|
var flash = Entities.addEntity({
|
||||||
type: "ParticleEffect",
|
type: "ParticleEffect",
|
||||||
position: position,
|
position: position,
|
||||||
|
|
|
@ -13,7 +13,8 @@ var rat = Entities.addEntity({
|
||||||
color: {red: 200, green: 20, blue: 200},
|
color: {red: 200, green: 20, blue: 200},
|
||||||
gravity: {x: 0, y: -9.8, z: 0},
|
gravity: {x: 0, y: -9.8, z: 0},
|
||||||
collisionsWillMove: true,
|
collisionsWillMove: true,
|
||||||
script: scriptURL
|
script: scriptURL,
|
||||||
|
userData: JSON.stringify({isShootable: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
|
|
Loading…
Reference in a new issue