Hi, I’ve seen all the forum topics on this subject but in my case the situation is a little bit different and I don’t know what to do
If someone helps me, I would be very grateful
I have an animator that when it is in the state of attack, it performs an animation (the attack animation).
What I want is when the attack button (space) is pressed (only once), the attack animation normally plays. “But”, when I press the space button (without dropping it), the animation stops at a certain specific Frame and, When I release the space button, the animation continues from the point where it stopped.
My code is almost identical to this (has more things), and i want something like that/this:
public class PlayerControls : MonoBehaviour {
private Animator anim;
void Awake() {
anim = GetComponent<Animator>(); }
void FixedUpdate()
{
Animation();
}
void Animation()
{
if ( Input.GetKeyDown(KeyCode.Space) )
{
anim.SetBool("Attack", true);
Attack();
}
else if ( Input.GetKey(KeyCode.Space) )
{
anim.SetBool("Attack", true);
anim.Stop( *at frame 35 of 68* );
if (Input.GetKeyUp(KeyCode.Space)) {
anim.Play(); // play from the frame 35 (when it stopped)
}
}
}