Guest User

Untitled

a guest
Oct 15th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Runtime.Remoting.Channels;
  5.  
  6. public class ManController : MonoBehaviour {
  7.  
  8. private Animator anim;
  9. public float moveSpeed = 0.5f;
  10. private CharacterController controller;
  11.  
  12. void Start () {
  13.  
  14. controller = GetComponent<CharacterController>();
  15. anim = GetComponent<Animator>();
  16. }
  17.  
  18. void Update () {
  19.  
  20. //get input key varaibles (between 0 and 1)
  21. var x = Input.GetAxis("Horizontal");
  22. var y = Input.GetAxis("Vertical");
  23.  
  24. Move(x, y);
  25. }
  26.  
  27. private void Move(float x, float y)
  28. {
  29.  
  30. anim.SetFloat("VelX", x);
  31. anim.SetFloat("VelY", y);
  32.  
  33.  
  34. transform.Translate(Vector3.forward * y * Time.deltaTime * moveSpeed);
  35. transform.Translate(Vector3.right * x * Time.deltaTime * moveSpeed);
  36.  
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment