mirror of
https://github.com/overte-org/overte.git
synced 2025-07-28 21:50:24 +02:00
explode heli
This commit is contained in:
parent
0650280fb6
commit
3c227db08d
2 changed files with 63 additions and 1 deletions
62
examples/helicopter/explodeHelicopter.js
Normal file
62
examples/helicopter/explodeHelicopter.js
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
var partsURLS = [
|
||||||
|
"https://s3.amazonaws.com/hifi-public/eric/models/blade.fbx",
|
||||||
|
"https://s3.amazonaws.com/hifi-public/eric/models/body.fbx",
|
||||||
|
"https://s3.amazonaws.com/hifi-public/eric/models/tail.fbx",
|
||||||
|
]
|
||||||
|
|
||||||
|
var parts = [];
|
||||||
|
|
||||||
|
var explodePosition;
|
||||||
|
var helicopter;
|
||||||
|
var entities = Entities.findEntities(MyAvatar.position, 2000);
|
||||||
|
for (i = 0; i < entities.length; i++) {
|
||||||
|
var name = Entities.getEntityProperties(entities[i], 'name').name;
|
||||||
|
if (name === "Helicopter") {
|
||||||
|
helicopter = entities[i];
|
||||||
|
explodeHelicopter(Entities.getEntityProperties(helicopter, 'position').position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function explodeHelicopter(explodePosition) {
|
||||||
|
Entities.deleteEntity(helicopter);
|
||||||
|
for (var i = 0; i < partsURLS.length; i++) {
|
||||||
|
var part = Entities.addEntity({
|
||||||
|
type: "Model",
|
||||||
|
modelURL: partsURLS[i],
|
||||||
|
position: explodePosition,
|
||||||
|
shapeType: "box",
|
||||||
|
damping: 0
|
||||||
|
});
|
||||||
|
parts.push(part);
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.setTimeout(function() {
|
||||||
|
parts.forEach(function(part) {
|
||||||
|
var naturalDimensions = Entities.getEntityProperties(part, "naturalDimensions").naturalDimensions;
|
||||||
|
Entities.editEntity(part, {
|
||||||
|
dimensions: naturalDimensions,
|
||||||
|
gravity: {
|
||||||
|
x: 0,
|
||||||
|
y: -9.6,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
velocity: {
|
||||||
|
x: Math.random(),
|
||||||
|
y: -10,
|
||||||
|
z: Math.random()
|
||||||
|
},
|
||||||
|
collisionsWillMove: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
parts.forEach(function(part) {
|
||||||
|
Entities.deleteEntity(part);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(cleanup);
|
|
@ -6,7 +6,7 @@ var spawnPosition = {
|
||||||
z: 1041
|
z: 1041
|
||||||
};
|
};
|
||||||
|
|
||||||
var speed = .15;
|
var speed = 0;
|
||||||
|
|
||||||
var helicopterSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/ryan/helicopter.L.wav");
|
var helicopterSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/ryan/helicopter.L.wav");
|
||||||
var audioInjector = Audio.playSound(helicopterSound, {
|
var audioInjector = Audio.playSound(helicopterSound, {
|
||||||
|
|
Loading…
Reference in a new issue