Forum rules - please read before posting.

Mixing point&click with straight-to-cursor / Realtime RPG movement.

edited March 2017 in Technical Q&A
This is my first post here on the forum. I apologize if my questions are uninformed or a repetition of commonly asked questions, but here we go:

I have been playing around with point&click movement, and before I decided to try AC, I had been working on a smooth kind of point&click using the Unity NavMesh, where a new destination raycast was sent continually when holding down the mouse button.

This type of movement is inspired by RPG games such as Diablo, Nox or Divinity.

I am trying to recreate this using AC, but with my limited programming experience, I haven't figured out how the AC scripts are composed, and I can't find the specific line where navigation destination is set with the mouse.

I still want to retain the "move to destination", but limit it to a quick mouse "tap", so I have both:

click-and-hold = continual movement (interrupted on MouseUp)
click once/tap = traditional point&click

How do I proceed on this issue?

Comments

  • Welcome to the community, @Antonius.

    Player movement calls are made in the PlayerMovement script, though writing a custom motion controller should be done through a separate script - see this tutorial.

    However, what you are seeking should already be possible by setting your Movement method to Straight To Cursor in your Settings Manager - see Section 2.6 of the Manual.

    The Player will then move towards the cursor whenever the mouse button is held.  Additional options under the Movement settings panel further down will then allow traditional point-and-click: Single-clicking also moves player? and Pathfind when single-clicking?.
  • Thank you for the reply!

    I am now trying to achieve what I want with the Straight To Cursor setting, however, there are still two things that I miss:

    One is the ability to use Pathfinding continually, not only limited to single-clicking. In the game I'm working on, there will be some obstacles on the roads that are annoying if the player doesn't automatically pathfind around them.

    The other is simply to be able to tweak the "single click speed". I find that I have to click very fast on the mouse to be able to do the single click function, and not just hold-and-interrupt for at split-second, walking only an inch.

    With these issues, do you recommend that I instead try to implement my own custom motion controller, or is it possible for me to do it in AC without a lot of scripting?
  • edited March 2017
    The first issue will either require a custom motion controller, or a rewrite of the Straight To Cursor method.  I will see if the latter is possible, but - if it is - you will need to set a non-zero "Pathfind update time" in the Settings Manager.  The issue is one of memory - continually pathfinding every frame would cause memory issues - so it wouldn't be possible to calculate a new path every frame.

    The second issue may be resolved by modifying the "Click delay" value in the PlayerInput component's Inspector (it's on the GameEngine), but I doubt it.  I will have to recreate your issue myself to see if it can be resolved.
  • Update: Yes, both issues are possible, but will require an update to AC's code.  Expect these included in v1.56b.
  • @Antonius: It's done!  v1.56b includes the ability to pathfind provided the pathfind update time is non zero, and a new slider allows you to set the duration that a single-click can register as such before becoming a "hold".
  • First of all, thanks for a great asset! 

    Secondly, I am also trying to use the click-and-hold continuous movement. What I want is for the character to walk towards the mouse cursor when the button is held down, and if I move the mouse (while holding down the mouse button) the character should follow, like in Diablo.

    I have set the Movement method to straight to cursor, but the character just moves to where the cursor was when I first clicked and held the button. It doesn't follow the mouse when I move it.

    Did I miss something?
  • edited March 2017
    Welcome to the community, @MrHellstorm.

    The Straight To Cursor method should allow the movement style you're looking for.  Are you using v1.56b?  Let's see the settings you have under the "Movement settings" panel in the Settings Manager.  A screenshot posted on imgur.com will help to see what's going on.

    So that we can eliminate the possibility of your player prefab being the cause of this, place in the 3D Demo game's Player prefab, Tin Pot, into the scene before running it to override your own.  He can be found in /Assets/Adventure Creator/Demo/Resources.
  • Thank you for the quick response, @ChrisIceBox!

    After updating the asset to v.1.56c it works like a charm. Thanks again!
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.