Jump to content
  • Advertisement
Sign in to follow this  
AndreiVictor

Unity Need your opinion: Input System of my engine.

This topic is 2987 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been creating a basic data-driven engine as practice problems for several years now -- trying to inject this activity on spare time. Recently, I've been constantly rethinking on how I should create my InputManager. To be specific, the part on what is best and comfortable interface for the programmer that will use the engine.

I've been deciding with two (or three?) styles of handling them...

1. A stack of action maps. An action map is simply a data structure where the program would just create a map, and add keys (or buttons) and a bind functor or delegate to execute whenever an input event comes (yes I have an event system ready). So far, I've seen this in Torque.

2a. The classic Java-style listener interface where all input goes into. Normally, one would explicitly access a specific game devices' class and get the state of the input device.

2b. Or, just let the programmer have direct access to the game devices and the states. Quite similar to Unity.

At first I would concentrate on the game engine to C++ users but my real aim to integrate the engine's functionality to a scripting language. So, integrating it to a scripting language in the future would be a plus.

What do you think?

I'm sorry if my english is poor.

Share this post


Link to post
Share on other sites
Advertisement
1) Don't make a game engine. Nobody will use it, the market is flooded by finished products which are a lot better.

2) I've been using the listener interface method for a while now, and its pretty good.

2a) There is no reason you can't do 2) and 2a) at the same time

d) You forgot about message queues. Each event gets translated into a game event and added to the event queue. You said you already had an event system, so simply make each input event send an in-game event to the queue.

Share this post


Link to post
Share on other sites
Quote:
Original post by speciesUnknown
d) You forgot about message queues. Each event gets translated into a game event and added to the event queue. You said you already had an event system, so simply make each input event send an in-game event to the queue.


Can you expound on the "send an in-game event to the queue."? What makes a game event and not a game event?

Currently, my event system is the one creating what I call "InputEvent" and queues it. These input events contain (for a keyboard), the game device, game device type, the key, and state (key down, key up, or key on hold). Then these input events are processed by action maps (as mentioned method 1 before). Is that what you mean? What do you think?

Share this post


Link to post
Share on other sites
Be wary of the listener approach to input devices: it doesn't play well with multi-threaded code. This is why both XNA and Unity3d opt for direct access to game devices (polling-based).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!