Skip to content

Instantly share code, notes, and snippets.

@atlass-dev
Created July 3, 2021 05:40
Show Gist options
  • Save atlass-dev/a84b1127c9de53364542dc583dedd767 to your computer and use it in GitHub Desktop.
Save atlass-dev/a84b1127c9de53364542dc583dedd767 to your computer and use it in GitHub Desktop.
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);
}
}
@baldasik
Copy link

i working with my project well thanks

@Zizuhuu
Copy link

Zizuhuu commented Oct 16, 2023

thx

@1ch4rl3S
Copy link

thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment