Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.Runtime.Remoting.Channels;
- public class ManController : MonoBehaviour {
- private Animator anim;
- public float moveSpeed = 0.5f;
- private CharacterController controller;
- void Start () {
- controller = GetComponent<CharacterController>();
- anim = GetComponent<Animator>();
- }
- void Update () {
- //get input key varaibles (between 0 and 1)
- var x = Input.GetAxis("Horizontal");
- var y = Input.GetAxis("Vertical");
- Move(x, y);
- }
- private void Move(float x, float y)
- {
- anim.SetFloat("VelX", x);
- anim.SetFloat("VelY", y);
- transform.Translate(Vector3.forward * y * Time.deltaTime * moveSpeed);
- transform.Translate(Vector3.right * x * Time.deltaTime * moveSpeed);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment