Entity Movement

I need help with this code, as it doesn’t work, and I don’t know why. This code should totally work!!

var ShipMovement = pc.createScript('shipMovement');

// initialize code called once per entity
ShipMovement.prototype.initialize = function() {
    
    //Movement Data
    var mX = 100;
    var mY = 0;
    var mZ = 0;
    
    //Liftoff Data
    var liftoffX = 0;
    var liftoffY = 5;
    var liftoffZ = 0;
    
    
    //Landing Data
    var landingX = 0;
    var landingY = -5;
    var landingZ = 0;
    
    //AngleChange Data
    angleChange1 = [];
    
    //Other Variables
    var isFinished = false;
};

// update code called every frame
ShipMovement.prototype.update = function(dt) {
    if(!isFinished) {
        var currentPos = this.entity.getPosition();

        //Lifetoff
        entity.translate(liftoffX, liftoffY, liftoffZ);
        
        //AngleChange1
        //To be emplemented
        
        
        
        //Main Movement
        entity.translate(mX, mY, mZ);
        
        //Landing
        entitiy.translate(landingX, landingY, landingZ);
        
        isFinished = true;
    }
};

// swap method called for script hot-reloading
// inherit your script state here
// ShipMovement.prototype.swap = function(old) { };

// to learn more about script anatomy, please read:
// http://developer.playcanvas.com/en/user-manual/scripting/

Developers daily job consists of debugging and investigations of problems, this is in fact majority of daily routine.
Read how to debug in browsers: http://developer.playcanvas.com/en/user-manual/scripting/debugging/
And many other sources of how to debug and work with problems which is skill you have to learn as developer in order to be a self sufficient game developer.

2 Likes

Thanks, but I was just wondering why the model wasn’t moving! But good suggestion! (I didn’t exactly word it correctly, then).

Happy Developing! :relaxed: