Greetings!
We Just started using spine in our studio a little while ago. I am getting a strange flicker effect when switching between animations while the character is attacking, and I'm not exactly sure why / how to go about fixing. after searching around with no avail I thought it time to ask the pros.
here is where the animations are being set.
using UnityEngine;
using System.Collections;
using Spine;
using Spine.Unity;
public class InverseDirection : MonoBehaviour
{
private float StartPos;
private float CurrentPos;
private PlayerControler player;
private float scale;
public Animator anim;
WeaponManager weaponManager;
GameObject wpn;
SkeletonAnimation skeletonAnim;
AudioSource source;
public AudioClip SFXStep;
string dir;
string newdir;
string currentDIR;
bool move;
// Use this for initialization
void Start ()
{
source = GetComponent<AudioSource> ();
scale = transform.localScale.x;
player = GameObject.FindWithTag ("Player").GetComponent<PlayerControler> ();
skeletonAnim = GetComponent<SkeletonAnimation> ();
wpn = GameObject.FindWithTag ("Player");
weaponManager = wpn.GetComponent<WeaponManager> ();
skeletonAnim.state.Event += OnEvent;
}
void OnEvent (Spine.TrackEntry entry, Spine.Event e)
{
if (e.Data.Name == "Footstep")
{
source.PlayOneShot (SFXStep,0.25f);
}
if (e.Data.Name == "Stop_Attack")
{
//skeletonAnim.state.SetEmptyAnimation (1,0f);
UpdateAnim ();
//skeletonAnim.skeleton.SetToSetupPose ();
skeletonAnim.state.ClearTracks ();
}
}
void Update()
{
if (currentDIR != weaponManager.faceDirection || move != player.MOVING)
{
UpdateAnim ();
}
currentDIR = weaponManager.faceDirection;
move = player.MOVING;
}
// Update is called once per frame
public void UpdateAnim ()
{
Debug.Log ("UPDATE ANIMATIONS");
CurrentPos = this.transform.position.x;
dir = weaponManager.faceDirection;
if (weaponManager != null)
{
if (player.MOVING == true )
{
switch (weaponManager.faceDirection)
{
case "DirRight":
skeletonAnim.state.SetAnimation (0, "Walk_Right", true);
break;
case "DirLeft":
skeletonAnim.state.SetAnimation (0, "Walk_Left", true);
break;
case "DirDown":
skeletonAnim.state.SetAnimation (0, "Walk_Front", true);
break;
case "DirUp":
skeletonAnim.state.SetAnimation (0, "Walk_Back", true);
break;
}
}
else
{
switch (weaponManager.faceDirection)
{
case "DirRight":
skeletonAnim.state.SetAnimation (0, "Idle_Right", true);
break;
case "DirLeft":
skeletonAnim.state.SetAnimation (0, "Idle_Left", true);
break;
case "DirDown":
skeletonAnim.state.SetAnimation (0, "Idle_Front", true);
break;
case "DirUp":
skeletonAnim.state.SetAnimation (0, "Idle_Back", true);
break;
}
}
}
newdir = weaponManager.faceDirection;
}
public void MeleeAttack(string attackType)
{
skeletonAnim.state.SetAnimation(1, attackType, false);
}
}
and a video to demonstrate the issue.
I apologize if this has already been solved and my googling is not up to par.
MOD EDIT