I was working on a little test and I was trying to see if I can make if statements because I’m not really good with conditions. I made a condition and it didn’t work. In fact, the part of the condition that was supposed to be executed was executed before the requirements were met.
Here is my test https://codepen.io/spookelix/pen/GRRNXeR
When using if statements,
== means s condition to checked to see if equal
= means set the variable to the value
there is a third type === which you don’t need to worry about for now, but good to know it exists.
So in your case this:
if (camera.position.x = 5, camera.position.y = -10,
camera.position.z = -4) {
is actually setting: x to 5, y to -10 and z to -4. Not checking if they are at that point.
Also, using comas in if statements is bad form, you should be using && (and), || (or), or &| (and or) to link statements together.
So to re-write:
if (camera.position.x == 5 && camera.position.y == -10 && camera.position.z == -4) {
camera.position.y = 4; // then move the camera's y cord to + 4
}