- Home /
 
               Question by 
               Phi999 · Apr 20, 2021 at 08:00 AM · 
                c#cameracontroller  
              
 
              Can't use wasd control in game!
I am trying yo make a unity game, and I have a camera controler with mouse + wasd. I have this code for the camera :
 using UnityEngine;
 using System.Collections;
 
 
 public class camera : MonoBehaviour {
 
 
     public float speedH = 2.0f;
     public float speedV = 2.0f;
 
     private float yaw = 0.0f;
     private float pitch = 0.0f;
 void Start(){
 
         Cursor.visible = false;
  Cursor.lockState = CursorLockMode.Locked;
  }
 
    public int speed;
 
     // Update is called once per frame
     void FixedUpdate()
     {
         Vector3 Movement = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
 
         this.transform.position += Movement * speed * Time.deltaTime;
     }
 
     void Update () {
      float xAxisValue = Input.GetAxis("Horizontal") * Time.deltaTime;
      float zAxisValue = Input.GetAxis("Vertical")* Time.deltaTime;
 
 
      if(Camera.current != null)
      {
          Camera.current.transform.Translate(new Vector3(xAxisValue, 0.0f, zAxisValue));
      }
         yaw += speedH * Input.GetAxis("Mouse X");
         pitch -= speedV * Input.GetAxis("Mouse Y");
 
         transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
     }
 }
I tried on other project and is working ! Why is this happening. I searched online and saw something about Ghost Keys, But I don't know what are those.
At the settings at Horizontal are the right keys. How can I solve this?
               Comment
              
 
               
              Answer by REDCRAFT123 · Apr 20, 2021 at 10:56 AM
Try using this: Replace input.getaxis.... with this Input.GetKey("w")
Your answer
 
 
             Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
How do I limit my chracters rotation on the X axis? 1 Answer
Camera Follow Player using a path 0 Answers
Detecting if background is clicked 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                