Multiple ways of doing it

Ive seen a few different ways on how to use the new input system. This seems to be the more complicated way, but I think this is also the propper way to do it. Is that correct?

I was looking for a course just like this that uses the new input system in this way. Using CallbackContext context, instead of something like… OnJump(InputValue value) which we did in the Tile mania 2D and the lazer defender 2D Projects.

It seems that both ways are completely different but both work well and one is far easier than the other… I wanted to learn both ways of doing it I just dont get why one way is better than the other?

1 Like

One of the reasons Unity made the new Input System the way they did is to remove the idea of the “proper” way, and instead to provide “many” ways.

It’s all a matter of context. The code based method we’re using here is complicated, and takes a bit of extra work to get going (though it’s easier than when the InputSystem was first introduced, thanks to the provided interfaces!). If all you needed was to know when the mouse has been clicked and at what location, this method would be wildly excessive when you could simply poll mouse.event.current. This method requires that every Input in the Action Scheme you’re implementing has a callback receiver (via the interface). With the method used in TileMania, you don’t have to worry about all of the actions in an Action Scheme, just the ones you need, meaning you can use the default actions and be up and running. For beginning students, this is easier to implement. In a more advanced course like this, we are using the code/interface method.

Ultimately, which method you use in a given project will be best determined by the complexity of the project.

2 Likes

Ok thank you for clearing that up :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms