Forum rules - please read before posting.

I have a question about the touchscreen joystick.

edited February 2023 in Technical Q&A

I saw that in the AC configuration manager there is a touch screen option. How do I put a joystick similar to the one in the image configured for a touch screen game that will work on android through AC.?

The game is in 2d.

https://uploaddeimagens.com.br/imagens/jVD6WUA

Comments

  • A ready-made "UI Template: Mobile Joystick" package can be found over on AC's Downloads page.

  • edited February 2023

    I downloaded and these two errors appear in the script

    Assets\AdventureCreator\Downloads\Mobile joystick\Scripts\SyncTouchAndCursorPosition.cs(67,36): error CS0122: 'PlayerInput.LockedCursorPosition' is inaccessible due to its protection level

    Assets\AdventureCreator\Downloads\Mobile joystick\Scripts\JoystickUI.cs(135,66): error CS0117: 'ACScreen' does not contain a definition for 'LongestDimension'

  • What is your AC version? You will need to use the latest release from the Package Manager for the API to be compatible with the download.

  • The AC I use is 1.73.5.

  • This copy of the game in the image is without the joystick download. The Package Manager version before was 3.2.17. Before updating to 4.3.3 it did not contain any errors, after the update two new errors appeared.

    https://uploaddeimagens.com.br/imagens/aM4bgdw

    https://uploaddeimagens.com.br/imagens/8q0iuU8

    Library\PackageCache\com.unity.xr.management@4.3.3\Editor\XRGeneralBuildProcessor.cs(38,52): error CS0117: 'BuildPipeline' does not contain a definition for 'GetBuildTargetName'

    Library\PackageCache\com.unity.xr.management@4.3.3\Editor\XRGeneralBuildProcessor.cs(90,52): error CS0117: 'BuildPipeline' does not contain a definition for 'GetBuildTargetName'

  • The only version that shows ''verified'' is the one I was using 3.2.17. Does an upgrade of unity to a newer version resolve this issue?

  • The error messages you are getting are not coming from AC, but are Unity-related. The XR framework package, however, is not involved with the joystick template - you do not need to import it for the template to work.

    You will, however, need to update your AC version - v1.73.5 is almost two years old, so the API won't be compatible with packages on the Downloads page.

    Back up your project, import the latest AC release from the Package Manager (currently 1.76.3) and the errors related to the joystick template should go.

  • I updated the AC and the errors disappeared, I dragged the Joystick object to the scene, I made the adjustments and the player works. However, there are no buttons on the screen, only the directional ones. How do I add the buttons on the screen?

  • You can use a regular Menu from the Menu Manager for that.

    Inside the Menu, create a Button element and set its Click type to Simulate Input. You can then enter the details of the input to simulate - e.g. a Button named InteractionA for left-clicks.

    See the Manual's "Input descriptions" chapter for details of what inputs are available to simulate in this way.

  • edited March 2023

    I created the menu button to jump, it worked on android, however the button only works if the player is stopped, if it is running the button does not work.

    And also if you place a finger on any part of the cell phone screen, and with another click on the jump button, the button does not work at the same time.

  • edited March 2023

    if the player is stopped, if it is running the button does not work.

    Is this because you've let go of the joystick? It sounds like these issues are related.

    Are you using Unity UI or AC for the Menu's Source?

  • yes I released the joystick.

    Are you using Unity UI or AC for the Menu's Source?
    I'm using AC.

  • edited March 2023

    Image of the game installed on the cell phone.

    https://uploaddeimagens.com.br/imagens/JdYgtIk

  • edited March 2023

    Today I downloaded the Joystick control system again, and I saw that a button was added. There is a problem that arises.

    Only the sound appears missing the jump when the button is clicked.

    I replaced the ''asset file'' with the one from the 2d demo download'' then the jump works without the audio in the original settings of the ''asset file'' of the demo.
    Check it out in the video below.

    It looks like some bug that the touch screen system is not working.

    When I tested it on android, clicking on the jump button while running, the click sound worked.

  • I'm not clear on your description. Are you asking for a sound field in the Inspector, to play when the button is pressed, or is the issue to do with the button not responding with your Settings Manager?

  • edited March 2023

    or is the issue to do with the button not responding with your Settings Manager?

    Yes, exactly.

  • I'll attempt a recreation. Does it respond if you set your "Input method" to "Mouse And Keyboard"?

  • edited March 2023

    I discovered the source of the problem, it is in the "Active Inputs", where I activated the sound, hence the origin of this conflict every time the key is clicked instead of jumping, the sound comes out. I removed the name on the Input button ''Jump'' from ''Active inputs'' and then it worked without the sound.

    Is there another way to put the sound in the jump?

  • You can attach a custom script to the Player that hooks into the OnPlayerJump custom event to fire off an AudioSource:

    using UnityEngine;
    using AC;
    
    public class JumpSound : MonoBehaviour
    {
    
        public AudioSource jumpAudioSource;
    
        private void OnEnable () { EventManager.OnPlayerJump += OnPlayerJump; }
        private void OnDisable () { EventManager.OnPlayerJump -= OnPlayerJump; }
    
        private void OnPlayerJump (Player player)
        {
            if (player.gameObject == gameObject)
                jumpAudioSource.Play ();
        }
    
    }
    
  • edited March 2023

    Worked, thank you.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.