overte/examples/moving-platform.js
Anthony J. Thibault 072172b1a2 SpatiallyNestable: now with velocity support!
Moved velocity and angularVelocity into the SpatiallyNestable base class.

Entity velocity and angularVelocity properties are now relative to their parent, similar to the way position and orientation work for entities.

MyAvatar rig animations now use SpatiallyNestable to convert velocity into local frame to drive the animation state machine.
2016-02-08 19:43:23 -08:00

40 lines
892 B
JavaScript

var platform;
function init() {
platform = Entities.addEntity({
name: "platform",
type: "Box",
position: { x: 0, y: 0, z: 0 },
dimensions: { x: 10, y: 2, z: 10 },
color: { red: 0, green: 0, blue: 255 },
gravity: { x: 0, y: 0, z: 0 },
visible: true,
locked: false,
lifetime: 6000,
velocity: { x: 1.0, y: 0, z: 0 },
damping: 0,
isDynamic: false
});
if (platform) {
if (MyAvatar.getParentID() != platform) {
MyAvatar.position = { x: 0, y: 3, z: 0 };
MyAvatar.setParentID(platform);
}
}
}
function update(dt) {
}
function shutdown() {
if (platform) {
MyAvatar.setParentID(0);
Entities.deleteEntity(platform);
}
}
Script.setTimeout(init, 3000);
Script.update.connect(update);
Script.scriptEnding.connect(shutdown);