Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlayerController : MonoBehaviour
- {
- [SerializeField]
- private float fPlayerSpeed = 20F;
- [SerializeField]
- private float fPlayerJumpVelocity = 150;
- private Vector3 v3Move;
- private Rigidbody rbPlayer;
- #region Animation
- private Animator anrPlayer;
- private int iJumpHash = Animator.StringToHash("Jump");
- private int iAttackHash = Animator.StringToHash("Attack");
- private int iForwardHash = Animator.StringToHash("Forward");
- private int iMovementButtons = 0;
- #endregion
- void Start () {
- rbPlayer = GetComponent<Rigidbody>();
- anrPlayer = GetComponentInChildren<Animator>();
- }
- void FixedUpdate () {
- v3Move.x = Input.GetAxisRaw("Horizontal") * fPlayerSpeed;
- v3Move.y = Physics.gravity.y;
- //v3Move.y = 0;
- v3Move.z = Input.GetAxisRaw("Vertical") * fPlayerSpeed;
- v3Move = transform.TransformDirection(v3Move);
- v3Move.Normalize();
- rbPlayer.velocity = v3Move*fPlayerSpeed;
- if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.S))
- {
- Debug.Log("FixedUpdate magnitude"+rbPlayer.velocity.magnitude);
- }
- }
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.S))
- {
- Debug.Log("Update magnitude" + rbPlayer.velocity.magnitude);
- }
- Debug.DrawLine(rbPlayer.position, v3Move);
- }
- void LateUpdate()
- {
- if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.S))
- {
- Debug.Log("Late magnitude" + rbPlayer.velocity.magnitude);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement