Created
July 3, 2021 05:40
-
-
Save atlass-dev/a84b1127c9de53364542dc583dedd767 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
[RequireComponent(typeof(Rigidbody), typeof (BoxCollider))] | |
public class PlayerController : MonoBehaviour | |
{ | |
[SerializeField] private Rigidbody _rigidbody; | |
[SerializeField] private FixedJoystick _joystick; | |
[SerializeField] private Animator _animator; | |
[SerializeField] private float _moveSpeed; | |
private void FixedUpdate() | |
{ | |
_rigidbody.velocity = new Vector3(_joystick.Horizontal * _moveSpeed, _rigidbody.velocity.y, _joystick.Vertical * _moveSpeed); | |
if (_joystick.Horizontal != 0 || _joystick.Vertical != 0) | |
{ | |
transform.rotation = Quaternion.LookRotation(_rigidbody.velocity); | |
_animator.SetBool("isRunning", true); | |
} | |
else | |
_animator.SetBool("isRunning", false); | |
} | |
} |
thx
спасибо!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thx