Brand new to Unity; setting up camera rotation and getting error CS1519: Unexpected symbol `)' in class, struct, or interface member declaration
using UnityEngine;
[RequireComponent(typeof(PlayerMotor))]
public class PlayerController : MonoBehaviour {
[SerializeField]
private float speed = 5f;
[SerializeField]
private float lookSensitivity = 3f;
private PlayerMotor motor;
void Start ()
{
motor = GetComponent<PlayerMotor> ();
}
void Update ()
{
float _xMov = Input.GetAxisRaw ("Horizontal");
float _zMov = Input.GetAxisRaw ("Vertical");
Vector3 moveHorizontal = transform.right * _xMov;
Vector3 moveVertical = transform.forward * _zMov;
Vector3 velocity = (moveHorizontal + moveVertical).normalized * speed;
//Apply movement
motor.Move (velocity);
//Calculate rotation as 3D vector (turning around)
float _yRot = Input.GetAxisRaw("Mouse X");
Vector3 _rotation = new Vector3 (0f, _yRot, 0f) * lookSensitivity;
//Apply rotation
motor.Rotate(_rotation);
}
//Calculate camera rotation as 3D vector (turning around)
float _xRot = Input.GetAxisRaw("Mouse Y");
Vector3 _cameraRotation = new Vector3 (_xRot, 0f, 0f) * lookSensitivity;
//Apply camera rotation
motor.RotateCamera (_cameraRotation)
}
Answer by Matthewj866 · Apr 26, 2017 at 02:50 AM
Hi there.
All this means is "lol you have a syntax error, go find it".
motor.RotateCamera (_cameraRotation)
is missing a semicolon. I didn't spot any other syntax errors in your code, but if this doesn't fix it then there are more.
Hope this helps.
That doesn't seem to fix it. I'm trying to set up the camera so that it will rotate up and down, but after adding the semicolon, motor.RotateCamera (_cameraRotation); is still not working. Since I am new, this script is based off of a tutorial series on YouTube, and the video was made in 2015. Could I be typing something that is no longer needed, or missing something that I would need that was not needed in 2015? I apologies if this isn't helpful, but I am $$anonymous$$ching myself and started only 3 days ago, so I barley even know what it is I'm doing AT$$anonymous$$.
Unity is a bit weird in the sense that it will flat out ignore scripts if they don't run correctly.
As mundane as it sounds I assume you saved the change? Unity doesn't run code that it can't compile and only uses the latest saved version.
Are there any new errors when you add that change?
Are you new to just Unity or C# as well?
Sorry if some of these questions are a bit mundane, but it's always good to check.
It's no problem.
Yes I saved and saved again to be sure.
No difference after adding change
I'm new to both Unity and C#. Backstory is I have a game design class and we just started coding for Unity. I won't attend next year but I still want to learn.
I should have noted that there is a second script: Player$$anonymous$$otor. It's where _cameraRotaion is based, however there are no errors in that script. The only problem in the entire system is that motor.RotateCamera (_cameraRotation); is not being recognized, or working; therefore I cannot enter play mode because of the error, and even if I could I still wouldn't be able to move up and down.