Hello Everyone! So I am not an experienced C# programmer and I am struggling to find the solution to the issues I am having with the camera movement script that I tried to make myself. The issue is as follows:
“Assets/CameraMovement.cs(8,18): error CS1519: Unexpected symbol ;' in class, struct, or interface member declaration" when removing the suspected "Unexpected symbol" it would come up with another compile error saying this: " Assets/CameraMovement.cs(13,5): error CS1519: Unexpected symbol
void’ in class, struct, or interface member declaration”.
When looking into this I understand that the missing “;” is the issue but it then comes up with the same error that is highlighted in red. I have tried everything but I think it’s best to get help from experts on these forums. The code is as follows:
using System.Collections;
using UnityEngine;
public class CameraMovement : MonoBehaviour {
public float hspeed;
public float vspeed;
public CamPos
// Update is called once per frame
void FixedUpdate () {
if (Input.GetKey(KeyCode.W)) {
transform.CamPos.y = new Vector2 (0,vspeed * Time.deltaTime * 5);
}
if (Input.GetKey(KeyCode.S)){
transform.CamPos.y = new Vector2 (0,vspeed * Time.deltaTime * -5);
}
if (Input.GetKey(KeyCode.A)) {
transform.CamPos.x = new Vector2 (hspeed * Time.deltaTime * 5,0);
}
if (Input.GetKey(KeyCode.D)) {
transform.CamPos.x = new Vector2 (hspeed * Time.deltaTime * -5, 0);
}
CamPos = Vector2(transform.position.x, transform.position.y);
}
}
The aim of this code is to get the camera to move with the keys WASD, as my game is the only 2D - I don’t think I need Vector3 but I might be wrong. If you can help me out, I will appreciate that most definitely!