Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Diagnostics;
- public class PlayerController : MonoBehaviour {
- public float input = 0;
- public float speed = 0.5f;
- Animator animator;
- Rigidbody rigidbody;
- // Use this for initialization
- void Start() {
- animator = GetComponent<Animator>();
- rigidbody = GetComponent<Rigidbody>();
- }
- void FixedUpdate() {
- float newSpeed = speed;
- rigidbody.AddRelativeForce(new Vector3(Input.GetAxisRaw("Horizontal") * newSpeed, 0, input = Input.GetAxisRaw("Vertical") * newSpeed), ForceMode.VelocityChange);
- animator.SetFloat("Movement", Mathf.Abs(rigidbody.velocity.x) + Mathf.Abs(rigidbody.velocity.z));
- }
- // Update is called once per frame
- void Update() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment