Answer the question
In order to leave comments, you need to log in
How to fix the control and camera script?
Good day to all. The question is actually this: there is a "player" in the form of a sphere, it moves with the help of a script:
public class Move : MonoBehaviour {
Rigidbody rb;
public float speed;
void Start () {
rb = GetComponent<Rigidbody> ();
}
void Update () {
float h = Input.GetAxis ("Horizontal");
float v = Input.GetAxis ("Vertical");
Vector3 move = new Vector3 (h*speed, 0, v*speed);
rb.AddForce (move);
}
}
public class CameraForward : MonoBehaviour {
public GameObject player;
Vector3 offset;
void Start () {
offset =transform.position - player.transform.position;
}
void Update () {
transform.position = player.transform.position + offset;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question