Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CharacterMotor : MonoBehaviour {
- // Animations du perso
- Animations animations;
- // Vitesse de deplacement
- public float walkSpeed;
- public float runSpeed;
- public float turnSpeed;
- // Inputs
- public string InputFront;
- public string InputBack;
- public string InputLeft;
- public string InputRight;
- public Vector3 jumpspeed;
- CapsuleCollider PlayerCollider;
- // Use this for initialization
- void Start () {
- animations = gameObject.GetComponent<Animations>();
- playerCollider = gameObject.GetComponent<CapsuleCollider>();
- }
- // Update is called once per frame
- void Update () {
- // si on avance
- if (input.Getkey(inputFront)) && Input.GetKey(KeyCode.leftShift))
- {
- transform.Translate(0,0, walkSpeed * time.deltaTime);
- animations.Play("walk");
- }
- // si on sprint
- if (input.Getkey(inputFront)) && Input.GetKey(KeyCode.leftShift))
- {
- transform.Translate(0,0, walkSpeed * time.deltaTime);
- animations.Play("run");
- }
- // si on recule
- if (Input.GetKey(InputBack))
- {
- transform.Translate(0, 0, -(walkSpeed / 2) * Time.deltaTime);
- Animations.Play("walk");
- }
- // rotation à gauche
- if (Input.GetKey(inputLeft))
- {
- transform.Rotate(0, -turnspeed * Time.deltaTime, 0);
- }
- // rotation à droite
- if (Input.Getkey(inputRight))
- {
- transform.Rotate(0, turnSpeed * Time.deltaTime, 0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement