so I cannot go into play mode because of an error with my code. The error message says “Identifier expected”.
here is my code
public class ThirdPersonMovement : MonoBehaviour
{
private CharacterController controller;
private float speed = 6f;
public CharacterController Controller { get => controller; set => controller = value;}
public float Speed { get => speed; set => speed = value;}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float horizontal = Input.GetAxisRaw(“Horizontal”);
float vertical = Input.GetAxisRaw(“Vertical”);
Vector3 direction = new Vector3(horizontal, 0f, vertical).normalized;
if (direction.magnitude >= 0.1f);
float = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, targetAngle, 0f);
controller.Move(direction * speed * Time.deltaTime);
}
}
Please post your code with this button in the future for better formatting:
Your problem is here:float = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
You are missing a name for the variable. I assume you wanted this because this name is used in the next line:float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
now I got two more errors one says “The type or namespace name ‘CharacterController’ could not be found (are you missing a using directive or an assembly reference?)” and the second says “The type or namespace name ‘MonoBehaviour’ could not be found (are you missing a using directive or an assembly reference?)”
You need using UnityEngine;
at the top of your file.
What are you using to edit your code? Visual Studio and other IDEs should add that for you automatically.
I use Mircosoft visual studio, also I have another error that says “Object reference not set to an instance of an object” but you don’t have to answer this.
How on earth are you typing this? Did you just read it as graffiti and you’re typing it in to see if it works?
To save you some time, let me assure you that with programming, 100% of everything has to be spelled properly, capitalized properly, punctuated precisely properly, and 100% of it has to be present. It’s not like writing text messages your phone where you can leave little bits out and misspell stuff. That’s not a thing.
yeah I know I just started to code with C# yesterday night.
Excellent! Welcome! Keep in mind all the things I say above because it applies to all programming, beginner and advanced, and this will help you be far more effective working through tutorials, and save you a lot of time.