Hello, I need help with my code for my basic scene that is for college. The objective is to create a camera that moves and then create a spotlight that moves with the camera and then when you press space-bar, the spotlight centers on the cube in the center of the floor. I hate just getting an answer with an explanation as that doesn’t lead to learning, it would be greatly appreciated for any and all help. I already created the cube, the floor, the point light, camera light. I am having trouble with adding Time.deltaTime to my movement. I have code that works normally for movement, but part of the grade is to add deltaTime to it so that the player’s movement is stable and predictable. This is the code that I am working with and I am getting an error with it.
public var speed = 5.0;
function Update ()
{
var xAxis : float = Time.deltaTime * speed;
transform.Translate(Input.GetAxis(“Horizontal”),
0,
var zAxis : float = Time.deltaTime * speed;
transform.Translate(Input.GetAxis(“Vertical”)));
//transform.Translate(Input.GetAxis(“Horizontal”) xAxis,
// 0,
//Input.GetAxis(“Vertical”) zAxis);
}
The commented out code is for the normal movement, so instead of adjusting that I made another so that incase I messed up, I would still have the original working code. Another part of my grade is to use the var zAxis and var xAxis as my new var’s. The error that I get is:
Error BCE0043: Unexpected token: var. (BCE0043) (Assembly-UnityScript) : It is for this line of code.
var zAxis : float = Time.deltaTime * speed;
I have no idea how to fix it but I have a feeling since that one is wrong, the next line is also wrong. What do I need to do to fix it?