(function(){ var self = this; this.preload = function(entityId) { this.entityId = entityId; this.yChange = 0.05; this.changeCount = 0; this.yaw = 0; print("preload entityId:" + entityId); } this.unload = function() { print("unload"); Script.update.disconnect(this.update); } this.update = function(deltaTime) { //print("update"); var properties = Entities.getEntityProperties(self.entityId); var newPosition = properties.position; newPosition.y = newPosition.y + self.yChange; self.yaw = self.yaw + 5; if (self.yaw > 360) { self.yaw = 0; } Entities.editEntity(self.entityId, { position: newPosition, rotation: Quat.fromPitchYawRollDegrees(self.yaw, self.yaw, self.yaw) }); self.changeCount++; if (self.changeCount > 10) { self.changeCount = 0; self.yChange = self.yChange * -1; } } Script.update.connect(this.update); });