4 Direction Attacking System

Game Editor comments and discussion.

4 Direction Attacking System

Postby DrakeStoel » Sat Oct 06, 2012 8:28 pm

I'm making a game where my actor can move four directions, and can attack in each of those four directions. I have a separate animation for each of those 4 attack directions, and want to use x to attack. I want to know how I could make him attack in the direction he's facing in, then return to the direction he was facing before he attacked.
DrakeStoel
 
Posts: 43
Joined: Wed Oct 03, 2012 8:53 am
Score: 2 Give a positive score

Re: 4 Direction Attacking System

Postby Soullem » Sun Oct 07, 2012 1:31 am

Are you using the animation system I showed you? If so all you have to do is create a button down event that changes stance to a new number, and then make that number change the stance string to attack. The direction part is already covered if you use this method.
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: 4 Direction Attacking System

Postby DrakeStoel » Sun Oct 07, 2012 1:45 am

Honestly, I'm not. I thought I had it figured out, but I didn't and instead of asking 6000 questions until I got it, I decided to just use separate actors for each colour.
DrakeStoel
 
Posts: 43
Joined: Wed Oct 03, 2012 8:53 am
Score: 2 Give a positive score

Re: 4 Direction Attacking System

Postby skydereign » Sun Oct 07, 2012 1:50 am

Well the normal way to do 4 directional movement (and attacking) is to have a variable that represents what direction the player is facing. Usually right=0, up=1, left=2, down=3. That way when you press attack, you can do this. There are examples on the forums of four directional movement and attacking if you need them.
Code: Select all
switch(dir)
{
    case 0:
    ChangeAnimation("Event Actor", "attack_r", FORWARD);
    break;

    case 1:
    ChangeAnimation("Event Actor", "attack_u", FORWARD);
    break;

    case 2:
    ChangeAnimation("Event Actor", "attack_l", FORWARD);
    break;

    case 3:
    ChangeAnimation("Event Actor", "attack_d", FORWARD);
    break;
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: 4 Direction Attacking System

Postby Soullem » Sun Oct 07, 2012 1:58 am

Thats okay... If you dont understand than I would prefer you to use a method that you do... Skys method will work great... And the more I think about it it gets better and better than mine...

As I said before I cant wait till you I can see this game in action!

P.S. Is it a legend of zelda game or just based off of it?
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: 4 Direction Attacking System

Postby DrakeStoel » Sun Oct 07, 2012 2:02 am

Ok, that works, but how do I make him return to the previous animation?
DrakeStoel
 
Posts: 43
Joined: Wed Oct 03, 2012 8:53 am
Score: 2 Give a positive score

Re: 4 Direction Attacking System

Postby Soullem » Sun Oct 07, 2012 2:05 am

Sky might have a better method but you can do an animation finish event. In the script for each attack just change the animation to the corresponding direction.
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: 4 Direction Attacking System

Postby DrakeStoel » Sun Oct 07, 2012 2:32 am

Ok, I've used this code in a key up event for x to change the animation back

Code: Select all
if (dir == 0)
{
    ChangeAnimation("Event Actor", "StandRight", FORWARD);
}
else if (dir == 1)
{
    ChangeAnimation("Event Actor", "StandUp", FORWARD);
}
else if (dir == 2)
{
    ChangeAnimation("Event Actor", "StandLeft", FORWARD);
}
else if (dir == 3)
{
    ChangeAnimation("Event Actor", "StandDown", FORWARD);
}


This works fine, but it only changes back after I release the x button. How would I make it stop almost right after you attack,no matter if your holding down the key or not?
DrakeStoel
 
Posts: 43
Joined: Wed Oct 03, 2012 8:53 am
Score: 2 Give a positive score

Re: 4 Direction Attacking System

Postby Soullem » Sun Oct 07, 2012 2:44 am

Dont make a key up, but an ANIMATION FINISH event. This can create an event that starts when an animation reaches its end.. (Which is what you are looking for)
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: 4 Direction Attacking System

Postby DrakeStoel » Sun Oct 07, 2012 2:48 am

I tried that already, but it doesn't work. He stays in the stab position until I press a direction key
DrakeStoel
 
Posts: 43
Joined: Wed Oct 03, 2012 8:53 am
Score: 2 Give a positive score

Re: 4 Direction Attacking System

Postby Soullem » Sun Oct 07, 2012 2:56 am

thats rather preculiar. doesn't make much sense, how did you set the coding for this?
If you did it right I don't know why that doesn't work. Sorry but I don't know if I can help. I'll test some things and see if I can find a smooth way.
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: 4 Direction Attacking System

Postby skydereign » Sun Oct 07, 2012 3:07 am

The animation finish event only triggers if your animation is more than one frame long. That might be the reason, or your ChangeAnimation call uses STOPPED as the state. My usual solution to this is to use the state method. http://game-editor.com/State_Method

That way, I can have an animation finish event for any animation (one script) that can reset the player's animation. It'd use a switch statement for the state variable that is able to tell if the player is attacking, and using direction you can reset it to the proper standing state.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: 4 Direction Attacking System

Postby DrakeStoel » Sun Oct 07, 2012 3:22 am

Yes, that's the problem. My animation ARE only one frame. But I'm confused on how/where I would put that switch statement into my script
DrakeStoel
 
Posts: 43
Joined: Wed Oct 03, 2012 8:53 am
Score: 2 Give a positive score

Re: 4 Direction Attacking System

Postby Soullem » Sun Oct 07, 2012 3:26 am

On one of my first games I had this problem. I was cheeky and added another frame of the same image. this will make it more than one frame and the animation finish event will work. just adjust the fraame rate to make him stab longer or slower.

Perhaps not the most legit method...
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: 4 Direction Attacking System

Postby DrakeStoel » Sun Oct 07, 2012 4:09 am

That works fine, but it still stays in the stab animation until I let go. I want it to stop after the animation finishes the first time

EDIT: Also, I want him to stop moving while he's attacking
DrakeStoel
 
Posts: 43
Joined: Wed Oct 03, 2012 8:53 am
Score: 2 Give a positive score

Next

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest