Quick Camera question

and now every “App” and “Force” got yellow underlines
and then when i tried to run it, my computer crashed

yes the camera error is gone

my whole code went X_X

Comment out the lines that you just added to the update() function and then add them back in one by one to find where the problem is.

comment out?

Yes, you can comment out lines of code by putting two forward slashes // in front them. This will turn the line green in the editor and the code will not run. It’s the same syntax as the comments you already have in your scripts.

so all my errors are gone except 1, which is just a yellow underline under this, and when i hover my mouse over it it says “x is used out of scope” or “right is used out of scope”
it is inside of my update function, and i dont know what else you need before you can figure this out, this code is in line 125-128

     //Use W-A-S ;
       x -= right.x;
       z -= right.z;
    };

The x, z, forward and right variables are used for the movement calculations. Your update function is still a mess, however. The update function closes on line 128 and then all your movement code is on lines 130-160. This is likely the reason you’re getting ‘out of scope’ errors.

Consider indenting your code, it’ll make it much easier to read and debug.

1 Like

so do i put the movement into the update? but then if i do that then it will all become underlined
but if its outside, it will say X is not defined as an error

If you want the movement code to run, it needs to be inside the update function. Make sure you declare the x, z, forward and right variables before you try to use them.

var forward = this.camera.forward;
var right = this.camera.right;

var x = 0;
var z = 0;

//The rest of your movement logic goes here

does my shooting code go into update too?
and now my it cant read keyboard of undefined

Yes, probably. Keep in mind, you probably shouldn’t have code outside of functions. Your scripts have a significant amount of code pasted randomly and not enclosed in functions. This will most likely continue causing problems for you until you clean it all up.

2 Likes

So I fixed some stuff, and organized it and now it says
Cannot Read Property ‘Keyboard’ of Undefined
this should be my last issue

This is not related to this topic. Please keep every problem in it’s own topic.

1 Like