mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 13:50:35 +02:00
screaming on grab. Need to get release working
This commit is contained in:
parent
dd3f1301e6
commit
de14fc64f6
2 changed files with 88 additions and 2 deletions
72
examples/toybox/entityScripts/doll.js
Normal file
72
examples/toybox/entityScripts/doll.js
Normal file
|
@ -0,0 +1,72 @@
|
|||
//
|
||||
// detectGrabExample.js
|
||||
// examples/entityScripts
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 9/3/15.
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// This is an example of an entity script which when assigned to an entity, will detect when the entity is being grabbed by the hydraGrab script
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
(function() {
|
||||
|
||||
var _this;
|
||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||
|
||||
// this is the "constructor" for the entity as a JS object we don't do much here, but we do want to remember
|
||||
// our this object, so we can access it in cases where we're called without a this (like in the case of various global signals)
|
||||
Doll = function() {
|
||||
_this = this;
|
||||
var screamSoundDirectory = HIFI_PUBLIC_BUCKET + "eric/sounds/"
|
||||
this.screamSound = SoundCache.getSound(screamSoundDirectory + "dollScream1.wav")
|
||||
this.startAnimationSetting = JSON.stringify({
|
||||
running: true
|
||||
});
|
||||
|
||||
this.stopAnimationSetting = JSON.stringify({
|
||||
running: false
|
||||
});
|
||||
};
|
||||
|
||||
Doll.prototype = {
|
||||
|
||||
|
||||
startNearGrab: function() {
|
||||
print("I was just grabbed... entity:" + this.entityID);
|
||||
Entities.editEntity(this.entityID, {
|
||||
animationSettings: this.startAnimationSetting
|
||||
});
|
||||
|
||||
var position = Entities.getEntityProperties(this.entityID, "position").position;
|
||||
print("POSITIONNN " + JSON.stringify(position))
|
||||
print("SCREAM SOUND ")
|
||||
Audio.playSound(this.screamSound[0], {
|
||||
position: position,
|
||||
volume: 0.1
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
release: function() {
|
||||
print("RELEASE")
|
||||
Entities.editEntity(this.entityID, {
|
||||
animationSettings: this.stopAnimationSetting
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
// preload() will be called when the entity has become visible (or known) to the interface
|
||||
// it gives us a chance to set our local JavaScript object up. In this case it means:
|
||||
// * remembering our entityID, so we can access it in cases where we're called without an entityID
|
||||
// * connecting to the update signal so we can check our grabbed state
|
||||
preload: function(entityID) {
|
||||
this.entityID = entityID;
|
||||
},
|
||||
};
|
||||
|
||||
// entity scripts always need to return a newly constructed object of our type
|
||||
return new Doll();
|
||||
})
|
|
@ -5,6 +5,8 @@ var resetKey = "resetMe";
|
|||
|
||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||
|
||||
var shouldDeleteOnEndScript = false;
|
||||
|
||||
|
||||
//Before creating anything, first search a radius and delete all the things that should be deleted
|
||||
deleteAllToys();
|
||||
|
@ -90,14 +92,23 @@ function createBasketBall(position) {
|
|||
|
||||
function createDoll(position) {
|
||||
var modelURL = "http://hifi-public.s3.amazonaws.com/models/Bboys/bboy2/bboy2.fbx";
|
||||
var animationURL = "https://hifi-public.s3.amazonaws.com/models/Bboys/zombie_scream.fbx";
|
||||
var animationSettings = JSON.stringify({
|
||||
running: false
|
||||
});
|
||||
|
||||
var scriptURL = Script.resolvePath("entityScripts/doll.js");
|
||||
// var scriptURL = Script.resolvePath("../entityScripts/sprayPaintCan.js");
|
||||
|
||||
var naturalDimensions = {x: 1.63, y: 1.67, z: 0.26};
|
||||
var desiredDimensions = Vec3.multiply(naturalDimensions, 0.15);
|
||||
|
||||
var entity = Entities.addEntity({
|
||||
type: "Model",
|
||||
name: "doll",
|
||||
modelURL: modelURL,
|
||||
animationSettings: animationSettings,
|
||||
animationURL: animationURL,
|
||||
script: scriptURL,
|
||||
position: position,
|
||||
shapeType: 'box',
|
||||
dimensions: desiredDimensions,
|
||||
|
@ -207,7 +218,10 @@ function cleanup() {
|
|||
deleteAllToys();
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
if(shouldDeleteOnEndScript) {
|
||||
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
}
|
||||
|
||||
function randFloat(low, high) {
|
||||
return low + Math.random() * (high - low);
|
||||
|
|
Loading…
Reference in a new issue