- Home /
Compiler error
Hello i'm making a third person Top Down shooter game. i started my Player Controller script to change the controls to WASD and Mouse and recieved some errors. Can an experienced person please look at my script i will leave the compiler errors also. Thanks
[1]: /storage/temp/79799-prob.png
using UnityEngine; using System.Collections; using System;
[RequireComponent(typeof(CharacterController))] public class PlayerController : MonoBehaviour {
public float rotationSpeed = 450;
public float walkSpeed = 5;
public float runSpeed = 8;
// System
private Quaternion targetRotation;
// Components
private CharacterController controller;
private Camera cam;
void Start() {
controller = GetComponent<CharacterController>();
cam = Camera.main;
}
void Update() {
ControlMouse();
//ControlWASD();
}
void ControlMouse() {
Vector3 mousePos = Input.mousePosition;
mousePos = cam.ScreenToWorldPoint(new Vector3(mousePos.x, mousePos.y, cam.transform.position.y - transform.position.y));
targetRotation = Quaternion.LookRotation(mousePos);
transform.eulerAngles = Vector3.up * Mathf.MoveTowardsAngle(transform.eulerAngles.y, targetRotation.eulerAngles.y, rotationSpeed * Time.deltaTime);
Vector3 input = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
Vector3 motion = input;
motion *= (Mathf.Abs(input.x) == 1 && Mathf.Abs(input.z) == 1) ? .7f : 1;
motion *= (Input.GetButton("Run")) ? runSpeed : walkSpeed;
motion += Vector3.up * -8;
controller.Move(motion * Time.deltaTime);
}
void ControlWASD() {
}
Vector3 input = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
if (Input != Vector3.zero) }
targetRotation = Quaternion.LookRotation(Input);
transform.eulerAngles = Vector3.up * Mathf.MoveTowardsAngle(transform.eulerAngles.y,targetRotation.eulerAngles.y,rotationSpeed * Time.deltaTime);
{
Vector3 motion = input;
motion *= (Mathf.Abs(input.x) == 1 && Mathf.Abs(input.z) == 1)?.7f:1;
motion *= (Input.GetButton("Run"))?runSpeed:walkSpeed;
motion += Vector3.up* -8;
controller.Move(motion* Time.deltaTime);
{
Answer by nksG · Oct 09, 2016 at 10:32 PM
After your function ControlWASD() , you have really messed up your brackets. this thing can't be compiled. Check your brackets carefully and it will work.
Answer by Kharief · Oct 10, 2016 at 05:13 AM
Its also telling me some of the line endings are MAC/WINDOWS does that have to do with anything? @nksG
This notification is something that Visual Studio shows even on perfect codes. Occasionally it is shown to me also, without knowing why, but there is no problem,don't worry about that.
Your answer
Follow this Question
Related Questions
Why won't my player rotation script work? 0 Answers
Unity Rotation Not Working Properly? 1 Answer
Compiler error - wrong target 1 Answer