Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Mavek · Jun 01, 2016 at 06:26 AM · errorstate-machine

State Machine Hell

Okay so, I came across a nice little fix for my menu and start game problem in my coding. The problem is that I got errors coming from every orifice mostly the top half. This is the template I had: http://gamedevelopment.tutsplus.com/articles/how-to-build-a-jrpg-a-primer-for-game-developers--gamedev-6676

And Unity was loving it for the first few bits. Any tips would help and other than the StateMachine I got it all word for word.

 class StateMachine {
     Map<String, IState> mStates = new Map<String, IState>();
     IState mCurrentState = EmptyState;
     StateMachine gGameMode = new StateMachine();
 
     gGameMode.Add("mainmenu", new MainMenuState(gGameMode));
     gGameMode.Add("openingscrean", new OpeningScreanState(gGameMode));
     gGameMode.Add("localmap", new LocalMap(gGameMode));
 
     gGameMode.Change("openingscrean");
 
     public void Update(float elapsedTime) {
         mCurrentState.Update(elapsedTime);
     }
     public void Update() {
         float elapsedTime = GetElapsedFrameTime();
         gGameMode.Update(elapsedTime);
         gGameMode.Render();
     }
     public void Render() {
         mCurrentState.Render();
     }
     public void Change(String stateName) {
         mCurrentState.OnExit();
         mCurrentState = mStates[stateName];
         mCurrentState.OnEnter();
     }
     public void Add(String name, IState state) {
         mStates[name] = state;
     }
 }
 


Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Mmmpies · Jun 01, 2016 at 07:47 AM 0
Share

Any chance you could post the errors you're getting?

avatar image Mavek · Jun 01, 2016 at 02:01 PM 0
Share

No problem, I also running 5.3.5. First and foremost "$$anonymous$$ap String, IState" is co$$anonymous$$g in as not found.

This little guy and his family is just said to be invalid:

gGame$$anonymous$$ode.Add("mainmenu", new $$anonymous$$ain$$anonymous$$enuState(gGame$$anonymous$$ode));

Should I make him a $$anonymous$$ethod?

avatar image Mmmpies Mavek · Jun 01, 2016 at 02:27 PM 0
Share

Just a note - you clicked on the big reply button, which means Answer not Reply! Not very intuitive but there you go. When replying you'll find a tiny Reply to the right of the name of the poster, or click Add Comment.

I've converted it to a comment this time :)

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Mmmpies · Jun 01, 2016 at 02:45 PM

As it turns out I could have just looked at that tutorial. Look at the top..

alt text

So that code you typed in is "Psudo JS" otherwise known as BS!

I'd find a different tutorial to go off if I were you and if possible try one that's C# unless you already know a fair bit JS. C# is faster in unity and if you're learning a new language anyway C# will be better as the unity tutorials are in that.

EDIT - got a bit of time to look and THIS looks pretty good if you're trying a 2D RPG style game.


bscode.png (16.7 kB)
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by ericbegue · Jun 02, 2016 at 07:28 AM

Hi,

Finite State Machine (FSM) can quickly become a hell to manage as the number of states is growing. Because the number of transitions grows quadratically and any modification to the state machine requires to fiddle with the transitions, which is tedious and error prone.

If you are looking for an alternative to FSM, have a look at Behaviour Tree, which is far more flexible and easier to manage.

I'm the author of Panda BT (www.pandabehaviour.com), it's a script based behaviour tree engine.

If you have a question about using this tool, you're welcome on this thread.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

68 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can't Open Exit Time Settings 0 Answers

Can someone help me? No matter what I change it still says "Parsing error". 2 Answers

NullReferenceExpection: Object reference not set to an instance of an object error. 1 Answer

Android Cardboard SDK published to WebGL 0 Answers

Can someone help me fix this script up? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges