i want moving platforms here’s my script
var Platform = pc.createScript('platform');
Platform.prototype.initialize = function() {
this.velocity = new pc.Vec3();
this.step = 0;
};
Platform.prototype.activate = function() {
this.active = true;
};
Platform.v3 = new pc.Vec3();
Platform.prototype.getVelocity = function(dt) {
var currentPosition = this.entity.getPosition();
var velocity = Platform.v3;
if (!this.lastPosition) {
this.lastPosition = new pc.Vec3().copy(currentPosition);
} else {
velocity.copy(currentPosition).sub(this.lastPosition).scale(1/dt);
this.lastPosition.copy(currentPosition);
}
return velocity;
};
Platform.prototype.postUpdate = function(dt) {
if (!this.active) return;
this.step += dt * 4;
this.entity.translate(Math.cos(this.step) * 0.3, 0, 0);
var velocity = this.getVelocity(dt);
this.app.fire('update-velocity', velocity);
};
it doesnt work, and it doesn’t give me errors so