So im making a game but for now im testing my skills can someone tell me what i did wrong here tho or just tell me how to make a walking script
//Scripted Variable Section
var Walking = pc.createScript('walking');
var MoveRight = new pc.Vec3(5,0,0);
//Regular Variable Section
var ypos;
var xpos;
var zpos;
var speed = 10;
//Function Usage
updatepos();
gotopos();
//Function Making
function updatePos(){
setTimeout(updatePos,100);
console.log("X:" + xpos + "Y:" + ypos + "Z:" + zpos + ";" + date + time);
time();
}
function keybindz(){
setTimeout(keybindz,1);
var onKeyDownE = function key1(e){
if(e.key === pc.KEY_LEFT){
xpos = xpos - speed;
}else{
if(e.key === pc.KEY_RIGHT){
xpos = xpos + speed;
}else{
if(e.key === pc.KEY_UP){
ypos = ypos + speed;
}else{
if(e.key === pc.KEY_DOWN){
ypos = ypos - speed;
}
}
}
}
e.event.preventDefault();
}
app.keyboard.on("keydown", onKeyDownE, this);
}
function gotopos(){
setTimeout(gotopos,40);
vec.x = xpos;
vec.y = ypos;
vec.z = zpos;
}
function time(){
//Todays Date
var dt = new Date();
var date = dt.toLocaleDateString();
//Live Time
var dt2 = new Date();
var time = dt2.toLocaleTimeString();
}
//Scripts
// initialize code called once per entity
Walking.prototype.initialize = function() {
};
// update code called every frame (40 milisec)
Walking.prototype.update = function(dt) {
};