Forum rules - please read before posting.

How would I add an input to the AC Joystic?

Hello everybody. I intend to add some inputs to the Joystic AC directions to trigger some animation or any other action, for example. I do not know how to do it

Comments

  • By "AC Joystic", are you referring to the "UI template: Mobile joystick" template on the Downloads page?

    If you're looking to have an on-screen button run an ActionList when pressed, you can do this with a Menu created in the Menu Manager.

    If you're looking to run an ActionList when a button on a gamepad is pressed, you can do this with an Active Input - see the Manual's "Active inputs" chapter for details.

  • By "AC Joystic", are you referring to the "UI template: Mobile joystick" template on the Downloads page?

    yes

  • You can duplicate or re-purpose the prefab's included "Jump" button object to create additional inputs.

    For each Button, register it in the root's Joystick UI component by increasing the "# of buttons" field and assigning it in a new slot.

    To have a given Button run an ActionList, assign an input name in its Inspector (it doesn't need to be listed in Unity's Input Manager), and then use that input name in an Active Input.

  • These additional buttons or inputs would have to correspond to the left and right directional buttons, when I click left or right on the AC joystic, any action in the actionList would have to be triggered. I'm not sure how the left or right directional pad would trigger the actionList button.

  • What's the exact behaviour you're looking for? For an ActionList to run whenever the joystick is moved? What Actions are you looking to run?

  • edited September 2023

    I have a ship game with multiple animations. The animations that I want to animate are the ship's weapons. When the ship goes forward, the triple shot will open and when it goes backwards, the triple shot will be closed, which will direct the shots in different directions. These weapons are objects added as children of the Player.

    So when the player goes forward or backward, the child objects will have a rotation, this opening and closing would be controlled by the player's movement while pressing forward or backward.

    The triple shots and their shooting locations have a custom script.

    Take the example of this Ship game, exactly what I want to do.

  • edited September 2023

    Thanks for the details. Though, this really isn't the kind of game AC is designed for. I recommend looking at another asset for arcarde shooting-style gameplay.

    That said, having an ActionList run when the Player changes direction is possible through scripting. It needn't be tied directly to the on-screen joystick: just read the Player's X-position and compare it with the previous frame.

    Something like this, ActionListOnDirection.cs, should do it:

    using UnityEngine;
    using AC;
    
    public class ActionListOnDirection : MonoBehaviour
    {
    
        public ActionListAsset forwardActionList;
        public ActionListAsset backwardActionList;
    
        float lastFrameX;
        int direction;
    
        void Update ()
        {
            float currentX = KickStarter.player.transform.position.x;
            if (currentX < lastFrameX)
            {
                if (direction != -1)
                {
                    direction = -1;
                    backwardActionList.Interact ();
                }
            }
            else if (currentX > lastFrameX)
            {
                if (direction != 1)
                {
                    direction = 1;
                    forwardActionList.Interact ();
                }
            }
    
            lastFrameX = currentX;
        }
    
    }
    
  • these errors appear;

    Assets\BT\SCRIPT\ActionListOnDirection.cs(19,13): error CS0019: Operator '<' cannot be applied to operands of type 'float' and 'Vector3'

    Assets\BT\SCRIPT\ActionListOnDirection.cs(27,18): error CS0019: Operator '>' cannot be applied to operands of type 'float' and 'Vector3'

    Assets\BT\SCRIPT\ActionListOnDirection.cs(36,22): error CS0029: Cannot implicitly convert type 'float' to 'UnityEngine.Vector3'

  • Sorry, typo. Try it now.

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.