mirror of
https://github.com/overte-org/overte.git
synced 2025-07-24 00:43:49 +02:00
Miniumum change for gun to use per-entity collisions.
I have *not* updated this script for other recent changes (e.g., to entityIDs).
This commit is contained in:
parent
050829e442
commit
d214f128cd
1 changed files with 21 additions and 22 deletions
|
@ -153,6 +153,26 @@ if (showScore) {
|
||||||
|
|
||||||
var BULLET_VELOCITY = 10.0;
|
var BULLET_VELOCITY = 10.0;
|
||||||
|
|
||||||
|
function entityCollisionWithEntity(entity1, entity2, collision) {
|
||||||
|
if (entity2 === targetID) {
|
||||||
|
score++;
|
||||||
|
if (showScore) {
|
||||||
|
Overlays.editOverlay(text, { text: "Score: " + score } );
|
||||||
|
}
|
||||||
|
|
||||||
|
// We will delete the bullet and target in 1/2 sec, but for now we can see them bounce!
|
||||||
|
Script.setTimeout(deleteBulletAndTarget, 500);
|
||||||
|
|
||||||
|
// Turn the target and the bullet white
|
||||||
|
Entities.editEntity(entity1, { color: { red: 255, green: 255, blue: 255 }});
|
||||||
|
Entities.editEntity(entity2, { color: { red: 255, green: 255, blue: 255 }});
|
||||||
|
|
||||||
|
// play the sound near the camera so the shooter can hear it
|
||||||
|
audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
||||||
|
Audio.playSound(targetHitSound, audioOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function shootBullet(position, velocity, grenade) {
|
function shootBullet(position, velocity, grenade) {
|
||||||
var BULLET_SIZE = 0.10;
|
var BULLET_SIZE = 0.10;
|
||||||
var BULLET_LIFETIME = 10.0;
|
var BULLET_LIFETIME = 10.0;
|
||||||
|
@ -178,6 +198,7 @@ function shootBullet(position, velocity, grenade) {
|
||||||
ignoreCollisions: false,
|
ignoreCollisions: false,
|
||||||
collisionsWillMove: true
|
collisionsWillMove: true
|
||||||
});
|
});
|
||||||
|
Script.addEventHandler(bulletID, "collisionWithEntity", entityCollisionWithEntity);
|
||||||
|
|
||||||
// Play firing sounds
|
// Play firing sounds
|
||||||
audioOptions.position = position;
|
audioOptions.position = position;
|
||||||
|
@ -310,27 +331,6 @@ function makePlatform(gravity, scale, size) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function entityCollisionWithEntity(entity1, entity2, collision) {
|
|
||||||
if (((entity1.id == bulletID.id) || (entity1.id == targetID.id)) &&
|
|
||||||
((entity2.id == bulletID.id) || (entity2.id == targetID.id))) {
|
|
||||||
score++;
|
|
||||||
if (showScore) {
|
|
||||||
Overlays.editOverlay(text, { text: "Score: " + score } );
|
|
||||||
}
|
|
||||||
|
|
||||||
// We will delete the bullet and target in 1/2 sec, but for now we can see them bounce!
|
|
||||||
Script.setTimeout(deleteBulletAndTarget, 500);
|
|
||||||
|
|
||||||
// Turn the target and the bullet white
|
|
||||||
Entities.editEntity(entity1, { color: { red: 255, green: 255, blue: 255 }});
|
|
||||||
Entities.editEntity(entity2, { color: { red: 255, green: 255, blue: 255 }});
|
|
||||||
|
|
||||||
// play the sound near the camera so the shooter can hear it
|
|
||||||
audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
|
||||||
Audio.playSound(targetHitSound, audioOptions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function keyPressEvent(event) {
|
function keyPressEvent(event) {
|
||||||
// if our tools are off, then don't do anything
|
// if our tools are off, then don't do anything
|
||||||
if (event.text == "t") {
|
if (event.text == "t") {
|
||||||
|
@ -505,7 +505,6 @@ function scriptEnding() {
|
||||||
clearPose();
|
clearPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity);
|
|
||||||
Script.scriptEnding.connect(scriptEnding);
|
Script.scriptEnding.connect(scriptEnding);
|
||||||
Script.update.connect(update);
|
Script.update.connect(update);
|
||||||
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
|
||||||
|
|
Loading…
Reference in a new issue