Hi,
Thank you always for all the great updates!!
Joystick use
I am using the included touchscreen joystick in a first person game and would like to be able to use both the Player and Camera joysticks simultaneously. It seems right now I need to let go of e.g. the player movement joystick before I can use the camera/look-arond joystick and vice versa. What can I change to be able to use both at the same time, e.g. look around while walking forward having both pressed at the same time?
Scrolling inventory
I have a one row inventory box with infinite slots and 8 visible slots. Instead of using back and forth buttons on either side, I'd like to be able to scroll left and right with the finger on the touch screen to slide the visible 8 slots. The scrolling should stop when reaching the current amount of inventory items held. Optimally it will scroll smoothly, i.e. not shift one inventory item at the time.
Thank you anyone who can help me with this!
// Magnus
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
One more thing. How do I disable one of the buttons temporarily without disabling the whole joystick? I have tried to disable the game object that holds the button component, but this only hides the button.
This should be the default behaviour. What device/platform are you building to, and what is your project's "Active Input Handling" set to?
A scrolling inventory can be achieved by creating all of the slots (not just the 8) in your UI prefab, referencing them in your Menu's InventoryBox element, and then using Unity UI's Scroll View to only show 8 at a time. I'm not sure about making "infinite", though - how many slots would you realistically need?
Disabling the Button GameObject won't currently prevent input - but it should do. I will update the template with this behaviour, thanks for the report. In the meantime, you could try moving the button off-screen, but I'll see about updating the template shortly.
Thanks a lot for this!!!
Joystick both buttons:
I'm building for iOS. Active input handling is set to "Both", although I tried the Old and the New as well with the same result. I am testing it through the unityRemote, so not sure if that can have anything to do with it.
Scrolling inventory
Yes, works great with Scroll Rect component and Unity UI!
Comment: The inventory items keep scrolling when dragging an item outside the "panel"-inventory box, although I solved this with
Works ok, but not sure what happens with screens of different resolutions?
Button disable
Ok, understood
Joystick new question. I've played around with the Joystick UI script and tried to add the below, but haven't managed to make it work
a. Redifining the player joystick to zoom in and out (spinning the view with the Camera joystick works fine)
b. disabling the player joystic, repositioning the camera joystick in the middle and adding a pinch zoom in and out to the same "button".
When using Input System, you'll need to have Use Enhanced Touch Support checked in your Controls Reader prefab, but it should work fine when using the older Input System.
However, multi-touch not working with Unity Remote is not supported IIRC.
You might be able to instead check for whether or not the mouse is currently over the Menu or not, which you can do with:
This is now the case - I've updated the template.
You could hook into the Joystick's OnJoystickStartMoving / StopMoving events to record the gap in time between releasing and re-controlling, and force the Player to run/walk, but you can't currently distinguish between the two provided joysticks. I'll look into this shortly.
I'll also see if it's possible to configure multiple joysticks, or affect the inputs used by them through external script.
Thanks a lot again
Where can I find the Controls Reader prefab? I don't seem to have it.
Mouse over menu.
This worked!:
https://imgur.com/a/vKhdxE0
I will try the Onjoystickstart moving, but with my skills I may wait for another solution... :-)
Thanks a lot!
It's part of AC's Input System integration package, which I recommend using if you want to switch over to Input System. It's available over on the Downloads page.
If you weren't using it, though, it's likely the issue is down to the limitation of Unity Remote.
It requires the latest version of AC to be installed.
Ok, great thanks. AC updated!
When importing the Input System integration package I get loads of errors though. E.g. Assets\AdventureCreator\Downloads\Input System integration\Scripts\ACCursorPositionProcessor.cs(4,19): error CS0234: The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)
All the errors refer to "The type or namespace name 'XXX' does not exist in the namespace 'UnityEngine'
I am using Unity 2021.3.8f1
I also got these errors when updating AC. Did I miss importing something?
https://imgur.com/a/UK4dcFf
Do you have Unity's Input System package already installed from the Package Manager?
No I didn't. Now I have and the Input system errors are gone. I still have the ActionCameraCheck ones though.
Sorry to mix different things, but they all happened at the same time so maybe related. I get these messages "The associated script cannot be loaded" for both the Input integration and the Mobile Joystick.
https://imgur.com/pCfn8rF
Hi, I all the above solved. I noticed I had a few scripts "e.g. ActionCameraCheck" in two places so when deleting the wrong ones all turned out good. Thanks again for all the help!
First time ever to try code with events... I've done the below hoping that the player (first person game) will start running when the gap is below a set threshold, but nothing happens.
I also tried to simulate my run Input Button "Run" with
instead of the isRunning = true, but no change there either. The player does run when pressing the assigned keyboard button though. I thought about just changing speed, but I'd like to keep the states of walk and run to attach sounds.
To have the effect only kick in when using the Player joystick, and not the Camera, you need to compare the event variable with that of the JoystickUI component.
You don't need to increase any timer in an Update loop - you can just use Time.time to record the time of the last touch.
Rather than trying to simulate the Run button, you're better off locking the Player's run state to either always walking, or running:
Thank you so much for this. It works great!
I had to change the "joystickUI.playerJoystick" from private to public in the JoystickUI script and it works like a charm!