Page 1 of 1

Punching

PostPosted: Fri Aug 13, 2010 4:40 am
by Setokyo
Hi
Can anyone so me how to punch for a platform game?
I have the one's for fighting but it's not helping
thanks
code would be lovely
:mrgreen:

Re: Punching

PostPosted: Fri Aug 13, 2010 6:30 pm
by BloodRedDragon
How do you mean? do you want a punching animation or script? I'ma guessing you want some script.
Well to make sure that the punch works on other actors, you need variables. make a variable (Actor variable, integer, no array) called Punch or Attack.

Then make a Key Down - Script editor event for your player(disable repeat):

ChangeAnimation("Event Actor", "(your punching animation)", FORWARD);
attack = 1;

Now you can use if(player.attack==1) with the other squiggly brackets in a collision - script editor event for the enemy, which means that the enemy will only react if the punch hits him. Put a Destroy actor(event actor) in the script editor as a result of the If statement if you want the enemy to die, or you could make him change animation if you want.

Hope that Helps,
:mrgreen:

Re: Punching

PostPosted: Fri Aug 13, 2010 7:41 pm
by Setokyo
Thanks for you help
1+ for you
any other ideas :mrgreen:

Re: Punching

PostPosted: Fri Aug 13, 2010 8:05 pm
by lcl
I have another way of doing it.
It is mostly like BloodRedDragons' way, but little different.

If you have punch animation that contains the whole punch move, you want him of course do
the move completely. So you can do it like that:

Create variable -> Attack - Integer - Global - Array: no

Key down, the key you want, repeat disable, script editor:

Code: Select all
if (Attack == 0)
{
ChangeAnimation(put here your punch animation);
Attack = 1;
}


And then, animation finish, punch animation, script editor:

Code: Select all
Attack = 0;


And in enemy, collision, any side, main actor, repeat yes, script editor:
Code: Select all
if (Attack == 0)
{
//Put here the code that takes life away.
}

if (Attack == 1)
{
DestroyActor("Event Actor");
}


This way you can hit once, then it plays the animation and then enables hit again when animation finishes. :D
And if you're colliding enemy while you punch, you will kill him. :)
I hope this helps you! :D

Re: Punching

PostPosted: Fri Aug 13, 2010 8:48 pm
by Setokyo
yea thanks
:mrgreen:

Re: Punching

PostPosted: Sat Aug 14, 2010 12:13 am
by BloodRedDragon
Thanks for the +1! Oh and yeah, i was gonna carry it further in a similar way to lcl, but to tell you the truth, I was testing out the whole punching idea myself. I have used 'if' before, just not for that.

Re: Punching

PostPosted: Sat Aug 14, 2010 12:48 am
by Setokyo
it's ok
try out my new demo
Zero madnesss