content/hifi-public/scripts/toybox/ping_pong_gun/wallTarget.js
Dale Glass 0d14e5a379 Initial data.
Needs a lot of cleanup. Data has been de-duplicated, and where identical copies existed, one of them
has been replaced with a symlink.

Some files have been excluded, such as binaries, installers and debug dumps. Some of that may still
be present.
2022-02-13 18:59:11 +01:00

56 lines
No EOL
1.9 KiB
JavaScript

// wallTarget.js
//
// Script Type: Entity
// Created by James B. Pollack @imgntn on 9/21/2015
// Copyright 2015 High Fidelity, Inc.
//
// This script resets an object to its original position when it stops moving after a collision
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
/*global print, MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */
(function() {
function Target() {
return;
}
Target.prototype = {
hasBecomeActive: false,
preload: function(entityID) {
this.entityID = entityID;
var SOUND_URL = "http://hifi-public.s3.amazonaws.com/sounds/Clay_Pigeon_02.L.wav";
this.hitSound = SoundCache.getSound(SOUND_URL);
},
collisionWithEntity: function(me, otherEntity) {
if (this.hasBecomeActive === false) {
var position = Entities.getEntityProperties(me, "position").position;
Entities.editEntity(me, {
gravity: {
x: 0,
y: -9.8,
z: 0
},
velocity: {
x: 0,
y: -0.01,
z: 0
}
});
this.audioInjector = Audio.playSound(this.hitSound, {
position: position,
volume: 0.5
});
this.hasBecomeActive = true;
}
}
};
// entity scripts always need to return a newly constructed object of our type
return new Target();
});