Page 1 of 1
Help with Weapon Movement Script
Posted:
Fri Sep 30, 2011 12:32 pm
by tnguy22
i'm a true beginner to GE but i've learned some scripting methods for moving a character around this board. So thanks for all of that!
The issue i have now is just testing a blade/hit animation. when the player is facing right and i hit the "a" key i want the sword hit animation to happen. so far it does work but it never comes out of the frame and go back to the standing right position.
here is the code im using for this. Any help would be greatly appreciated
char *key = GetKeyState();
if(animindex == getAnimIndex("StandRight"))
{
if (key[KEY_a]==1)
{
ChangeAnimation("Event Actor", "SwordRight", NO_CHANGE);
}
else if(key[KEY_a]==0)
{
ChangeAnimation("Event Actor", "StandRight", NO_CHANGE);
}
}
Re: Help with Weapon Movement Script
Posted:
Fri Sep 30, 2011 11:48 pm
by skydereign
By any chance do you have a collision script that changes the actor to stand? It sounds like the problem is that the animation is being reset, and that else if you have there in the code will never trigger if you are attacking. Notice it is in an if, that checks if the animation is the StandRight animation. So, if it isn't, it will never run the else if that resets your animation to StandRight. Am I right to assume you put this in the draw actor event?
Re: Help with Weapon Movement Script
Posted:
Mon Oct 03, 2011 10:28 am
by tnguy22
at the moment i have no Collision written. im just wanting to get all of the movements coded first then move on to the more detailed part of the game. which i'm sure i'll need help with as well lol
thanks for the reply
Re: Help with Weapon Movement Script
Posted:
Mon Oct 03, 2011 11:16 am
by foleyjo
Heres how I would do it
- Code: Select all
char *key = GetKeyState();
if (key[KEY_a] && animindex == getAnimIndex("StandRight"))
ChangeAnimation("Event Actor", "SwordRight", NO_CHANGE);
if (!key[KEY_a] && animindex != getAnimIndex("StandRight"))
ChangeAnimation("Event Actor", "StandRight", NO_CHANGE);
However thinking ahead this would cause problems unless the player can only hit from facing right while standing still.
If the player can also swing the sword while walking then it would have to be
- Code: Select all
char *key = GetKeyState();
if (key[KEY_a] && animindex != getAnimIndex("SwordRight"))
ChangeAnimation("Event Actor", "SwordRight", NO_CHANGE);
if (!key[KEY_a] && animindex != getAnimIndex("StandRight"))
ChangeAnimation("Event Actor", "StandRight", NO_CHANGE);
Re: Help with Weapon Movement Script
Posted:
Mon Oct 03, 2011 8:58 pm
by tnguy22
thanks foleyjo,
the code didnt work 100% properly as it basically killed all of my other movement functions. but i toyed with it and got it working properly
thanks for the help and i'll give you +2 for the code bc it helped me further along my game
Cheers!