A error syntax in my code

var Playermovement = pc.createScript(‘playermovement’);

Playermovement.attributes.add(‘movementSpeed’, {type: ‘number’});

Playermovement.attributes.add(‘turnSpeed’, {type: ‘number’});

Playermovement.attributes.add(‘jumpHeigth’, {type: ‘number’});

// initialize code called once per entity

Playermovement.prototype.initialize = function()

{

};

Playermovement.prototype.update = function(dt)

{

//movement

if (this.entity.name == (‘Player1’))

{

if (this.app.keyboard.isPressed(pc.KEY_S))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_W))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_A))

{

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_D))

{

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(this.movementSpeed))

}

//rotation

if (this.app.keyboard.isPressed(pc.KEY_Q))

{

this.entity.rigidbody.applyTorque(0,this.turnSpeed,0)

}

if (this.app.keyboard.isPressed(pc.KEY_E))

{

this.entity.rigidbody.applyTorque(0,-this.turnSpeed,0)

}

var Playermovement = pc.createScript(‘playermovement’);

Playermovement.attributes.add(‘movementSpeed’, {type: ‘number’});

Playermovement.attributes.add(‘turnSpeed’, {type: ‘number’});

Playermovement.attributes.add(‘jumpHeigth’, {type: ‘number’});

// initialize code called once per entity

Playermovement.prototype.initialize = function()

{

};

Playermovement.prototype.update = function(dt)

{

//movement

if (this.entity.name == (‘Player1’))

{

if (this.app.keyboard.isPressed(pc.KEY_S))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_W))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_A))

{

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_D))

{

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(this.movementSpeed))

}

//rotation

if (this.app.keyboard.isPressed(pc.KEY_Q))

{

this.entity.rigidbody.applyTorque(0,this.turnSpeed,0)

}

if (this.app.keyboard.isPressed(pc.KEY_E))

{

this.entity.rigidbody.applyTorque(0,-this.turnSpeed,0)

}

//else.if

if (this.entity.name == (‘Player2’))

{

if (this.app.keyboard.isPressed(pc.KEY_DOWN))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_UP))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_LEFT))

{

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_RIGHT)) {

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(this.movementSpeed))

}

{

//rotation

{

if (this.app.keyboard.isPressed(pc.KEY_SHIFT))  {

this.entity.rigidbody.applyTorque(0,this.turnSpeed,0);

}

if (this.app.keyboard.isPressed(pc.KEY_CONTROL))   {

this.entity.rigidbody.applyTorque(0,-this.turnSpeed,0);

}

{

//jump

{

if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {

this.entity.rigidbody.applyForce(0,this.jumpHeigth,0);

}

}

//else.if

if (this.entity.name == (‘Player2’))

{

if (this.app.keyboard.isPressed(pc.KEY_DOWN))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_UP))

{

this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_LEFT))

{

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(-this.movementSpeed))

}

if (this.app.keyboard.isPressed(pc.KEY_RIGHT)) {

this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(this.movementSpeed))

}

{

//rotation

{

if (this.app.keyboard.isPressed(pc.KEY_SHIFT))  {

this.entity.rigidbody.applyTorque(0,this.turnSpeed,0);

}

if (this.app.keyboard.isPressed(pc.KEY_CONTROL))   {

this.entity.rigidbody.applyTorque(0,-this.turnSpeed,0);

}

{

//jump

{

if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {

this.entity.rigidbody.applyForce(0,this.jumpHeigth,0);

}

};

I can’t find where my error is it

Uncaught SyntaxError: Unexpected end of input

SyntaxError: Unexpected end of input

I don’t understand what exactly it mean it like my third day in coding and the video tutorial is two year old so i believe it migth be a language error but im not exactly

Hi @Lea-Maude_Lavigne_Au and welcome! :waving_hand:

It looks like your code was pasted twice by mistake. Below the code I cleaned it up a bit and put it into one single script that should work. Please let me know if it works and send a link to your project if you need more help.

var Playermovement = pc.createScript('playermovement');

Playermovement.attributes.add('movementSpeed', {type: 'number'});
Playermovement.attributes.add('turnSpeed', {type: 'number'});
Playermovement.attributes.add('jumpHeight', {type: 'number'});

// initialize code called once per entity
Playermovement.prototype.initialize = function() {
};

// update code called every frame
Playermovement.prototype.update = function(dt) {
    // Movement for Player 1 (WASD)
    if (this.entity.name === 'Player1') {
        if (this.app.keyboard.isPressed(pc.KEY_S)) {
            this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(-this.movementSpeed));
        }
        if (this.app.keyboard.isPressed(pc.KEY_W)) {
            this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(this.movementSpeed));
        }
        if (this.app.keyboard.isPressed(pc.KEY_A)) {
            this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(-this.movementSpeed));
        }
        if (this.app.keyboard.isPressed(pc.KEY_D)) {
            this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(this.movementSpeed));
        }

        // Rotation for Player 1 (Q/E)
        if (this.app.keyboard.isPressed(pc.KEY_Q)) {
            this.entity.rigidbody.applyTorque(0, this.turnSpeed, 0);
        }
        if (this.app.keyboard.isPressed(pc.KEY_E)) {
            this.entity.rigidbody.applyTorque(0, -this.turnSpeed, 0);
        }

        // Jump for Player 1 (F)
        if (this.app.keyboard.wasPressed(pc.KEY_F)) {
            this.entity.rigidbody.applyForce(0, this.jumpHeight, 0);
        }
    }

    // Movement for Player 2 (Arrow keys)
    if (this.entity.name === 'Player2') {
        if (this.app.keyboard.isPressed(pc.KEY_DOWN)) {
            this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(-this.movementSpeed));
        }
        if (this.app.keyboard.isPressed(pc.KEY_UP)) {
            this.entity.rigidbody.applyForce(this.entity.forward.clone().mulScalar(this.movementSpeed));
        }
        if (this.app.keyboard.isPressed(pc.KEY_LEFT)) {
            this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(-this.movementSpeed));
        }
        if (this.app.keyboard.isPressed(pc.KEY_RIGHT)) {
            this.entity.rigidbody.applyForce(this.entity.right.clone().mulScalar(this.movementSpeed));
        }

        // Rotation for Player 2 (Shift/Ctrl)
        if (this.app.keyboard.isPressed(pc.KEY_SHIFT)) {
            this.entity.rigidbody.applyTorque(0, this.turnSpeed, 0);
        }
        if (this.app.keyboard.isPressed(pc.KEY_CONTROL)) {
            this.entity.rigidbody.applyTorque(0, -this.turnSpeed, 0);
        }

        // Jump for Player 2 (Space)
        if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {
            this.entity.rigidbody.applyForce(0, this.jumpHeight, 0);
        }
    }
};