Forum rules - please read before posting.

AdvancedThirdPersonCamera and Point and Click movement

Hi Chris and hi to all.
I can't find a solution for use the nice movement of drag camera "AdvancedThirdPersonCamera" with my Point and Click movement on mobile game.

When i mark "Is drag-controlled" i get the fluid and nice movement of the camera but when i drag with my finger... the navmesh read 1 touch and the player move.

Are there a method for use the "is drag-controlled" movement of the AdvancedThirdPersonCamera without move the player every time i drag on the display?

I've try to implement the SimpleTouchController with the Wiki integration but the movement of the camera is not so kind as the AdvancedThirdPersonCamera drag controlled.

Thanks,
Paolo

Comments

  • Ok, sorry. After 3 hour i've find the solution ;)

    On Setting - Double Click Movement = Required to walk.

    So i can drag the camera without move the player. :)

  • Recreated. Not immediately obvious how to work around it, but I will have a think.

  • edited December 2019

    Try this. Create a new Input button in the Input Manager named "Drag", and map it to "mouse 0" as the Positive Button.

    Then attach the following script as a component to the Third Person Camera:

    using UnityEngine;
    using AC;
    
    public class FixDragging : MonoBehaviour
    {
    
        private string dragInputName = "Drag";
        private bool pointAndClicked = false;
    
        void Start ()
        {
            KickStarter.playerInput.InputGetButtonDelegate = CustomGetButton;
        }
    
        void OnEnable ()
        {
            KickStarter.playerInput.dragOverrideInput = dragInputName;
            EventManager.OnPointAndClick += OnPointAndClick;
        }
    
        void OnDisable ()
        {
            KickStarter.playerInput.dragOverrideInput = string.Empty;
            EventManager.OnPointAndClick -= OnPointAndClick;
        }
    
        void OnPointAndClick (Vector3[] pointArray, bool run)
        {
            pointAndClicked = true;
        }
    
        void Update ()
        {
            if (Input.GetMouseButtonUp (0))
            {
                pointAndClicked = false;
            }
        }
    
        bool CustomGetButton (string name)
        {
            if (name == dragInputName && pointAndClicked)
            {
                return false;
            }
    
            try
            {
                return Input.GetButton (name);
            }
            catch {}
            return false;
        }
    
    }
    
  • Wonderful Chris!
    In about 4 hour i’ll try Your script and i think it will be the perfect solution. Thanks a lot! 🎄😊
  • Ok, Chris. I've tried your script but it work in strange mode.
    Now when i click on navmesh the drag camera don't work but work only if i press out of the navmesh.

    I'm searching a mode to disable the input on the navmesh if i press for dragging the camera also on navmesh.
    Thanks for the time and for helping this beautiful community,
    Paolo

  • Now when i click on navmesh the drag camera don't work but work only if i press out of the navmesh.

    That was my undertstanding of what you wanted. The script works by disabling camera dragging if you moved the player with the same click - in order to prevent both occuring at the same time.

    Detecting a drag input takes a frame longer than detecting a movement click - because the movement click is detected on the "down".

    You could try overriding the InteractionA input detection to have it only detect "up" clicks:

    using UnityEngine;
    using AC;
    
    public class FixDragging : MonoBehaviour
    {
    
        private string dragInputName = "Drag";
    
        void Start ()
        {
            KickStarter.playerInput.InputGetMouseButtonDownDelegate = CustomGetMouseButtonDown;
        }
    
        void OnEnable ()
        {
            KickStarter.playerInput.dragOverrideInput = dragInputName;
        }
    
        void OnDisable ()
        {
            KickStarter.playerInput.dragOverrideInput = string.Empty;
        }
    
        bool CustomGetMouseButtonDown (int button)
        {
            if (button == 0)
                return Input.GetMouseButtonUp (button);
    
            return Input.GetMouseButtonDown (button);
        }
    
    }
    

    This'll only have an effect when using Mouse And Keyboard input for now, but see how you go with this first.

  • Thanks Chris but don't work fine.
    When i click on navmesh the player move 1 click every 10 in random mode.

    I've tryed to put a Debug.Log here:

    bool CustomGetMouseButtonDown (int button)
    {
    if (button == 0)
    return Input.GetMouseButtonUp (button);
    Debug.Log("clicked");

        return Input.GetMouseButtonDown (button);
    }
    

    and on console i get many many log very fast.

    I don't understand.

  • Try this:

    using UnityEngine;
    using AC;
    
    public class FixDragging : MonoBehaviour
    {
    
        private string dragInputName = "Drag";
    
        void Start ()
        {
            KickStarter.playerInput.InputGetMouseButtonDownDelegate = CustomGetMouseButtonDown;
        }
    
        void OnEnable ()
        {
            KickStarter.playerInput.dragOverrideInput = dragInputName;
        }
    
        void OnDisable ()
        {
            KickStarter.playerInput.dragOverrideInput = string.Empty;
        }
    
        bool CustomGetMouseButtonDown (int button)
        {
            if (button == 0)
            {
                bool clickUp = Input.GetMouseButtonUp (button);
                if (clickUp) KickStarter.playerInput.ResetMouseClick ();
                return clickUp;
            }
    
            return Input.GetMouseButtonDown (button);
        }
    
    }
    
  • Yes, Chris. Many Thanks. In this mode work fine.
    The problem is when i left the mouse button down the player go to this point. :)
    Probably there is a method to cancel the click on navmesh after 1 second so if i drag the camera for 1 or 2 second the click on navmesh is cancelled when i left the button.
    I'll search this method on the web and i'll come back if i'll find it.
    Many Thanks for the time and the support.
    Paolo :)

  • It sounds like you have very specific behaviour in mind. You can cancel the player's movement at any time with:

    AC.KickStarter.player.EndPath ();
    
  • Thanks, Chris. Have a good new year!

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.