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