/// /// monster_v1.js /// A little angry monster /// Attach to an entity /// /// Author: Elisa Lupin-Jimenez /// Copyright High Fidelity 2017 /// /// Licensed under the Apache 2.0 License /// See accompanying license file or http://apache.org/ /// /// All assets are under CC Attribution Non-Commerical /// http://creativecommons.org/licenses/ /// (function () { var GROWL_URL = "https://hifi-content.s3.amazonaws.com/elisalj/emoji_scripts/behaviors/sounds/monster-growl.wav"; var GROWL = SoundCache.getSound(Script.resolvePath(GROWL_URL)); var _entityID; var props = Entities.getEntityProperties(_entityID); this.preload = function(entityID) { _entityID = entityID; props.position.y = MyAvatar.position.y - 1; Entities.editEntity(_entityID, props); }; Audio.playSound(GROWL, { position: props.position, volume: 0.3 }); var destination = Vec3.normalize(Vec3.subtract(props.position, MyAvatar.position)); Script.setInterval(function () { print("Velocity: " + JSON.stringify(props.velocity)); props.velocity = destination; Entities.editEntity(_entityID, props); }, 2000) this.unload = function() { // UI and Cache cleanup etc happen here, }; });