kot14217

public void SetCharacterState(string state)
{
if (state.Equals("DASH"))
{
SetAnimation(DASH, true, 1f); <======ERORR=====
}
currentState = state;
}
void Dash()
{
if (Input.GetKeyDown(KeyCode.LeftControl) && !lockDash)
{
lockDash = true;
Invoke("DashLock", 2f);
SetCharacterState("DASH");
rigidbody.velocity = new Vector2(0, 0);
if (rigidbody.transform.localScale.x < 0)
{
rigidbody.AddForce(Vector2.left * DashImpulse);
}
else
{
rigidbody.AddForce(Vector2.right * DashImpulse);
}
}
}
The animation of the Skeleton is not played completely or does not have time to be played when the character makes a jerk, how do I make a specific DASH animation lose completely when I press left ctrl?Help please
kot14217
  • Postovi: 8

Nate

If you get an error, show the error.

Your code appears to be all application code, not Spine Runtimes API, so we can't tell what is doing.
Avatar
Nate

Nate
  • Postovi: 11875

kot14217

there is no mistake!the animation plays very fast that it is not even visible!How can I just play an animation so that it doesn't end in a split second????
kot14217
  • Postovi: 8

Mario

All we see is a call to SetAnimation() that's relevant to Spine. And that will do what the documentation says: playback the animation at the speed you created in the Spine Editor, unless you modified TrackEntry.TimeScale, which is not happening here, or pass a delta time to AnimationState.Update() that is not based on wall clock time (default).

My guess is that you are calling your SetState() method over and over again, at least once per frame. That will restart the animation every time you call SetAnimation().
Avatar
Mario

Mario
  • Postovi: 3043

Nate

His SetAnimation(DASH, true, 1f); code isn't even AnimationState API. AnimationState setAnimation takes int, String, boolean, so we can't know what his code is doing at all.

You need to simplify your code to the simplest example and show usage of the Spine Runtimes API.
Avatar
Nate

Nate
  • Postovi: 11875

kot14217

Mario je napisao/la:All we see is a call to SetAnimation() that's relevant to Spine. And that will do what the documentation says: playback the animation at the speed you created in the Spine Editor, unless you modified TrackEntry.TimeScale, which is not happening here, or pass a delta time to AnimationState.Update() that is not based on wall clock time (default).

My guess is that you are calling your SetState() method over and over again, at least once per frame. That will restart the animation every time you call SetAnimation().
SetCharacterState("DASH"); -do you mean that this line???
could you write then what to write instead so that Dash is played completely? as an example

---

public void SetAnimation(AnimationReferenceAsset animation, bool loop, float timeScale)
{
if (animation.name.Equals(currentAnimation))
{
return;
}
Spine.TrackEntry animationEntry = skeletonAnimation.state.SetAnimation(0, animation, loop);
animationEntry.TimeScale = timeScale;
animationEntry.Complete += animationEntry_Complete;
currentAnimation = animation.name;
}
here is my code. Now, could you help???

---

public void SetAnimation(AnimationReferenceAsset animation, bool loop, float timeScale)
{
if (animation.name.Equals(currentAnimation))
{
return;
}
Spine.TrackEntry animationEntry = skeletonAnimation.state.SetAnimation(0, animation, loop);
animationEntry.TimeScale = timeScale;
animationEntry.Complete += animationEntry_Complete;
currentAnimation = animation.name;
}



here is my code. Now, could you help???

---

public void SetAnimation(AnimationReferenceAsset animation, bool loop, float timeScale)
{
if (animation.name.Equals(currentAnimation))
{
return;
}
Spine.TrackEntry animationEntry = skeletonAnimation.state.SetAnimation(0, animation, loop);
animationEntry.TimeScale = timeScale;
animationEntry.Complete += animationEntry_Complete;
currentAnimation = animation.name;
}
here is my code. Now, could you help???
kot14217
  • Postovi: 8

Nate

We would like to help. We have very little to go on. Maybe your time scale is wrong, set it to 1 instead. Otherwise it's not possible to tell what the problem is. If it's not the time scale, you'll need to create the simplest possible code that shows the problem so we can help.
Avatar
Nate

Nate
  • Postovi: 11875


Natrag na Editor