This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

Question

 

I'm trying to make a smash styled fighting game. Trying to use states. its not going to well. My big problems are.

 

1. Transitioning from state to state.

 

2. I want standard states for all characters but the action within said states to be individual. e.g. if one character does a punch their punch can combo into a second punch while another character only has one.

 

I'm trying to make a decent framework so that when I start production in earnest all I'll have to do is drag and drop. 

 

Thats the plan at least.

 

I included my script in the bottom. pretty sure its garbage though.

 

Any help offered would be appreciated.

Please login or register to see this attachment.

Share this post


Link to post
Share on other sites

4 answers to this question

  • 1

Posted (edited)

My University course covers Finite State Machines in an interesting way.

They start basic. Create Enum States

Please login or register to see this code.

Then use a Switch statement to set up basic stats

 

Please login or register to see this code.

Then for AI, use this but start to implement rules

- IF the player is blocking,  avoid attacking
- IF already attacking AND player is blocking, complete attack and jump back to avoid counter

- IF player is attacking AND cpu is not attacking AND is close enough to get hit, block/defend

You get the point, you can implement these simple rules using IF statement and AND operators (&&).

Edit:

A little extra thing. Always start with a basic state system like this.
After this is in you can add in sub-states, for example.

 

Please login or register to see this code.

Then you can store previous state to check for combo attacks.

 

Please login or register to see this code.

 

Edited by Calum.McManus
Extra Info
1 person likes this

Share this post


Link to post
Share on other sites
  • 0

My other question would be how to switch between the states. preferably on a button press.

Share this post


Link to post
Share on other sites
  • 0
Please login or register to see this quote.


So when you start the game normally you will be in the attack state.

While in the attack state you will control your current state by making attacks.

For example.

Please login or register to see this code.

So set up your input manager to have the Kick and Punch buttons and set up functions to perform the attacks and to set your attackstate.

 

So this will only matter while you are in the Attack State and if you get stunned or you are trying to block you won't be able to attack or effect your attack state.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now