1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { public float jumpSpeed; public float speedOfPlayer; public float jetPackForce; public float Sensivity; private Rigidbody rb; private Vector3 rotate = Vector3.zero; // Use this for initialization void Start () { rb = GetComponent<Rigidbody> (); } // Update is called once per frame void Update () { //PLAYER MOVEMENTS //LEFT if (Input.GetKey (KeyCode.A)) { transform.Translate (Vector3.left * speedOfPlayer * Time.deltaTime); } //RIGHT if (Input.GetKey (KeyCode.D)) { transform.Translate (Vector3.right * speedOfPlayer * Time.deltaTime); } //FORWARD if (Input.GetKey (KeyCode.W)) { transform.Translate (Vector3.forward * speedOfPlayer * Time.deltaTime); } //BACK if (Input.GetKey (KeyCode.S)) { transform.Translate (Vector3.back * speedOfPlayer * Time.deltaTime); } //JETPACK bool jetPackAct = Input.GetButton ("Jump"); if (jetPackAct) { rb.AddForce (0, jetPackForce, 0); } //LOOK AROUND float x_axis = Input.GetAxisRaw ("Mouse Y"); float y_axis = Input.GetAxisRaw ("Mouse X"); Vector3 lookAround_x = new Vector3 (0f, x_axis, 0f)* Sensivity; if (Input.GetButton ("Mouse X")) { transform.localRotation = lookAround_x; //transform.Rotate = (0, Input.GetAxis ("Mouse X") * Sensivity, 0); } } } |
Salut, j’ai crée un charcter controller mais je n’arrive pas à "lui faire tourner la tète" comment il faudrait faire?
Mer ci
+0
-0