It's a simple way to doing it i prefer to create a script called InputHandler/InputManager. In the script you only need to subscribe (+=) the inputs to a property and you can call them basiclly from everywhere. like... InputAsset.InputMap.InputAction.performed += context => MyProperty = context.ReadValue<Vector2>(); The good thing about this is, you are creating the script once and it's pretty performance friendly (I think) because you are only subscribing in input, thats the good new feature ig. So you need only to create instances of InputManger everywhere, you can do it as a singleton but i don't like singleton that much. If you are you can create like PlayerInputManager... etc. for every single input map but thats too much imo.
@Jackson-di1fi
8 ай бұрын
😜 'PromoSM'
@HehJimbow187
Жыл бұрын
Thank you so much for this tutorial this give me some Ideas on how the input system to be used. <3
@pyakpepyak
Жыл бұрын
You don't really need a separate ActionInputManager script just to enable or disable input asset. It all can be done via corresponding InputActionReference in your TestScript
@xepherin_dev
Жыл бұрын
For sure you can. This is the way Unity does it in their XR Interaction Toolkit so its just what I'm familiar with. You can also just add InputActions instead of InputActionReferences to skip the InputActionAsset altogether and do it all in the Inspector and enable the Actions themselves in your script. It's all in what you prefer.
@newleafgames
Жыл бұрын
You really have just helped me out. Very well explained.
@EvaSienna
Жыл бұрын
Many thanks! There are so many tutorials that explain how to use the system without explaining why you're coding what you're coding, what the purpose of anything even is.. Found this really helpful as a total unity noob, appreciate the explanations greatly 🥰
@xepherin_dev
Жыл бұрын
Great to hear! I wish you luck on your Unity journey
@rubenvidorreta8082
Жыл бұрын
Isn't just better to generate the C# class from the input action asset and use the interface given? It is easier for me at least
@xepherin_dev
Жыл бұрын
Definately you can do that! I prefer serializing as it's a hair faster due to all the string comparisons and C#'s static not being super fast. But if you're getting it all on startup and want to keep it all in the code that's definately a good way to keep it clean.
@enesgamedev
Жыл бұрын
thx
@sKryly1
Жыл бұрын
I just did the same thing you did, just an unnecessarily complicated version of it. I feel dumb and happy at the same time. Glad I found your video!
@njerurichard3581
Жыл бұрын
Hi. Any pointers on how to implement this for touch screens? Particularly how to use for example two buttons for left and right instead of an onscreen joystick. I am honestly at my wits end.
@StinkySteak
Жыл бұрын
There is OnScreenButton script, there is also a small doc about it
@njerurichard3581
Жыл бұрын
I am aware of that, but implementing it and tying it back to the input asset is a whole different matter. I know it sounds and looks trivial, but it is not.
@xepherin_dev
Жыл бұрын
Unfortunatly, mobile games is not something I have a ton of practice in. In the past, I've gotten a touch as two speparate InputActions, one for the touch event and one for the screen position [which you have to convert to world space through Camera.main.ScreenToWorldPoint()]. and then code a joystick from scratch. for buttons, I would just stick to the unity UI buttons as much as possible. For reading the input I would subscribe to an event on the touch and then Camera.main.ScreenToWorldPoint(touchPos.action.ReadValue<Vector2>()); within that event. Hope this helps!
@reeceytaylor
Жыл бұрын
Any plans to continue this series?
@xjaker91x
Жыл бұрын
Great video. If somebody wants to generate NSFW content, that is doable with changing a few lines of code :)
Пікірлер