Hey all, quick question about controllers and animations. I have a prefab set up for my character with controls with animations controlled via "Animators" which I think is Mecanim. The actual animations are tied to the Sprite currently, which is a child of the main prefab. I'm a little confused about how this interacts with ORK. I'd like to use what I have but I want ORK to be able to recognize the different states (i.e idle, walk, jump, etc). Thank you for any help!


This is the control script I am using currentlyimage

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
public Rigidbody theRB;
public float moveSpeed, jumpForce;

private Vector2 moveInput;

public LayerMask whatIsGround;
public Transform groundPoint;
private bool isGrounded;

public Animator anim;

public SpriteRenderer theSR;

private bool movingBackwards;

public Animator flipAnim;


// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
moveInput.x = Input.GetAxis("Horizontal");
moveInput.y = Input.GetAxis("Vertical");
moveInput.Normalize();

theRB.velocity = new Vector3(moveInput.x * moveSpeed, theRB.velocity.y, moveInput.y * moveSpeed);

anim.SetFloat("moveSpeed", theRB.velocity.magnitude);

RaycastHit hit;
if(Physics.Raycast(groundPoint.position, Vector3.down, out hit, .3f, whatIsGround))
{
isGrounded = true;
} else
{
isGrounded = false;
}

if(Input.GetButtonDown("Jump") && isGrounded)
{
theRB.velocity += new Vector3(0f, jumpForce, 0f);
}

anim.SetBool("onGround", isGrounded);

if(!theSR.flipX && moveInput.x < 0)
{
theSR.flipX = true;
flipAnim.SetTrigger("Flip");

} else if(theSR.flipX && moveInput.x > 0)
{
theSR.flipX = false;
flipAnim.SetTrigger("Flip");
}

if(!movingBackwards && moveInput.y > 0)
{
movingBackwards = true;
flipAnim.SetTrigger("Flip");
}
else if (movingBackwards && moveInput.y< 0)
{
movingBackwards = false;
flipAnim.SetTrigger("Flip");
}
anim.SetBool("movingBackwards", movingBackwards);
}
}
  • Why would ORK need to recognize the animation state?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I guess it doesn't, I'm just trying to set up Legacy Animations but I already have a character controller. Do I start with the Legacy From Scratch?
  • In that case, you can e.g. use the auto animation setup in ORK's combatants to handle your movement automation for you. You still have to set up the animation component with all the animations, as well as set them up in ORK as usual.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.