- Home /
Stop player movement and play attack animation
I have searched and searched the forums and I have seen a few about castlevania 4 whip animation and collision here and there, but this is different. Probably a much simpler question, hopefully with a much simpler answer.
I've been using Sprite Manager 2 for animation and sprite atlas building.
Yes I am new to using Sprite Manager 2 and Yes, new to using Unity as well. I've been working on a prototype for a game that is like a metroid-vania with Dark Souls style death treatment. Don't ask, I like to punish people I guess haha.
ANYWAYS! So... I have a punching animation, works standing still, but while running it doesn't play. I put a 'print ("ATTACK RIGHT");' and also for left to show that the attack is technically happening. But how do I stop the player from moving... and then play the animation?? I hate to be such a noob, but you have to start somewhere. I would appreciate any help from anyone. I may just be overlooking or overthinking this. I need an outsider opinion!!
Thanks in advance! Let me know what else you need in terms of info.
I have that variable "var attack : boolean = false;" outside the update (). So I have it only playable while it's false, because during the attack it's true so i figured that would stop it from being spammable? Maybe I need a WaitForSeconds()??? I dunno!!
//punch right
if (Input.GetButtonDown("Attack") && moveDirection == 1 && velocity.x == 0)
{
attack = true;
Sprite.DoAnim(8);
print ("ATTACK RIGHT");
}
//punch left
if (Input.GetButtonDown("Attack") && moveDirection == 0 && velocity.x == 0)
{
attack = true;
Sprite.DoAnim(9);
print ("ATTACK LEFT");
}
//running punch right
if (Input.GetButtonDown("Attack") && moveDirection == 1 && velocity.x > 0)
{
attack = true;
Sprite.DoAnim(8);
print ("ATTACK RIGHT WHILE RUNNING");
}
//running punch left
if (Input.GetButtonDown("Attack") && moveDirection == 0 && velocity.x < 0)
{
attack = true;
Sprite.DoAnim(9);
print ("ATTACK LEFT WHILE RUNNING");
}
Your answer
Follow this Question
Related Questions
Castlevania style stop and attack script. 0 Answers
The name 'PackedSprite' does not denote a valid type ('not found') 3 Answers
Changing number of frames in uvAnimationTileX 0 Answers
When i make my character animated, he can only move up, down left and right (2D) (JS) 0 Answers
2D Sprite animation - How do I jump to the next frame? 0 Answers