- Home /
Question by
Johnscaban · Aug 16, 2021 at 08:31 PM ·
c#animationjoystick
I have this problem when animating my character?
I don't want people to think that I'm spamming, I am just stuck with this problem. Here is a video of my problem (video) and here is my PlayerAnimator script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAnimator : MonoBehaviour
{
Player player;
Animator animator;
public Joystick leftJoystick;
public Joystick rightJoystick;
void Start()
{
player = FindObjectOfType<Player>();
animator = GetComponentInChildren<Animator>();
}
void Update()
{
if (leftJoystick.Direction == Vector2.zero)
{
animator.SetFloat("inputX", 0f);
animator.SetFloat("inputZ", 0f);
}
if (rightJoystick.Direction == Vector2.zero)
{
animator.SetBool("isAttacking", false);
}
if (leftJoystick.Direction != Vector2.zero)
{
animator.SetFloat("inputX", 0f);
animator.SetFloat("inputZ", 1f);
}
if (rightJoystick.Direction != Vector2.zero)
{
animator.SetBool("isAttacking", true);
animator.SetFloat("inputX", leftJoystick.Horizontal);
animator.SetFloat("inputZ", leftJoystick.Vertical);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
How to play animation (C#) 3 Answers
Animation at the end of the level 1 Answer