here is my code :
using UnityEngine;
using System.Collections;
public class playerMovement : MonoBehaviour {
private Vector3 input;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
input = new Vector3 (Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical"));
print (input);
}
}
1 Answer
1
If you’re not making a huge massive game you could do the below code in C#.
public float speed = 5.0f;
if (Input.GetKey (KeyCode.W)) {
transform.Translate (Vector3.forward * speed * Time.deltaTime);
}
if (Input.GetKey (KeyCode.S)) {
transform.Translate (Vector3.back * speed * Time.deltaTime);
}
if (Input.GetKey (KeyCode.A)) {
transform.Rotate (0,-5,0);
}
if (Input.GetKey (KeyCode.D)) {
transform.Rotate (0,5,0);
}
Kindly specify the expected output and the current output.
– HarshadKwhat happens if you move your input out of your Vector3 maker
– 767_2First, this is not a question. Second, make sure your axis are defined (and named properly) inside the project settings.
– Andres-Fernandez