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