Hello, I'm finalizing my new game Soul Tolerance (you can try a demo HERE), and I'd like to enhance a bit how the point and click movement method works.
Since my game has a rather wide camera and lot of walking/running around (as you can see if trying the demo), I wish to enhance user's experience by having a "refresh of mouse click on holding down the button".
Now, I thought that "Straight To Cursor" (plus ticking "single click moves the player" and also "double click for run") was doing exactly that, but it doesn't work (if I set "straight-to-cursor" plus those two options, it basically behaves exactly like point and click... holding down the left mouse button does nothing. I've tried to change pathfinding update to 0 and to 0.1, same result).
So either my straight-to-cursor is not working for some weird reasons, or it is not the right approach.
I'll try to explain myself better.
Now, if I want to run to a point, I double click to that point on my ground (navmesh), but if I want to run for a lot (i.e. to a point way out of the camera view), I'm forced to double-click, wait to reach a point, double-click again, wait, and so on... which is basically spamming often the left mouse button and that can be frustrating. (something similar happens also in Three Minutes To Eight, released last Monday, especially on the long side-scrolling street scene... By the way, Chris, feel free to include it in the "Made with AC" games).
So my idea is the following:
I wonder if there is already something like this integrated with AC (i.e. the Straight To Cursor? But then why is not working on my end?), or if someone ever tried this before with AC (I've found THIS on the forum, but it mentions again the straight to cursor, and I can't reproduce).
I've read the Manual about straight-to-cursor, but I'm probably missing something... Could it be that some UI is blocking my "movement to cursor" as if the camera + mouse position is somehow not working? Some missing raycast? Where could I investigate something like that?
P.S.
Unity 2021.1.3
AC 1.76.1
P.P.S.
A screenshot with the Movement Settings can be found HERE.
P.P.P.S.
I tested the straight-to-cursor method on "Three Minutes To Eight" and it works as intended, I'll include it with the next patch. Not sure why I cannot make it work in "Soul Tolerance"...
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
UPDATE:
I've found where the problem was...
In the "Game Engine / Player Input" I had for some reasons "Mouse Mid Button" as "Drag Override Input"... (maybe for something related with camera spinning?) So basically the "straight-to-cursor" was assigned to it!!! DANG!!!
I'm leaving this post in case someone else has a similar issue.
Now it almost works as intended... From my "bullet-points-wishlist" above, just this point is missing:
Meaning: everything works great, but my Click Marker Prefab is not "updating" to the new path. It's a prefab with a glowing ring, which disappears when the player stops. The problem is if I click on a point, then hold and drag my player to another direction, that click marker prefab keeps glowing on a totally different point, and disappears only when I stop running. How can I "teleport" it to the new pathfinding destination?
The Click Marker prefab will spawn on the first click. For holding the mouse down, a custom script may be necessary.
What are your current "Movement settings" properties in the Settings Manager?
I shared the Movement Settings at the end of my first post.
One more thing... I noticed that I cannot return to "walk" if I drag the mouse away from player (it starts to run) and then going back closer to it (it still runs).
And a couple more things which are not tuned perfectly...
And regarding the "walk/run" drag of my previous message, I think the issue is related with my camera angle and camera distance from player... For example, if the camera is behind and I move the mouse a bit farther, it works, but if I move it at the bottom of the screen, it requires more space (due to the perspective and cursor position in space). Is it possible to calculate the drag run threshold based on the "projection screen" of the camera, rather than real world distance? (i.e. 50 pixels on screen away from the player, rather than 20 units away in the real world)
(note: the trigger is running in the background, but still would be nice to find a way to interrupt the "hold" left mouse button)
I was dealing with something similar a while ago:
https://www.adventurecreator.org/forum/discussion/13545/straight-to-cursor-movement-run-threshold#latest
I solved it by using the hidden variable Chris added to PlayerMovement, which can be set through custom script.
Sorry, it's been too long! The hidden variable was for a different effect. But I'm pretty sure I dealt with the walk-run issue somewhere in the thread above.
I will add an option to continue to spawn the Click marker if the Player moves due to the holding-down of the mouse button to pathfind when using Straight To Cursor movement.
I cannot recreate such behaviour - check that this is still the issue in the latest release (using a backup/duplicate project). If it is, share your full Settings Manager.
A custom script can disable Movement when entering a Trigger, until mouse input is no longer detected:
Using another custom script, it should be possible to dynamically alter this value at runtime, based on the viewport position difference between the Player and the cursor:
Thanks a lot for all the info! I'll give it a try in the next days!
All right, I've made some tests...
The TriggerForceRelease.cs seems to work.
The ScreenBasedRunThreshold.cs not really.
Not sure if I'm doing something wrong or what... But basically if I click and hold, and drag the mouse away from my player, it actually runs, but when I move the mouse again closer to my player, it somehow freaks out... Meaning: it keeps running, until there's some warning about pathfinding method in the consoles. (I've tried different combinations of the "factor", but still...).
On this screenshot you can have an idea of my game camera point of view.
Waiting for this, I've added this script to my Click Marker prefab and it seems to work... Not the prettiest, but somehow it does the job. What do you think? Any way to make it better?
Let's try a different approach.
Before, the threshold was based on the screen distance between the mouse and the Player.
Instead, let's try having it lerp between a fixed range, based on "how much further above" the cursor is than the Player, in screen-space:
Ok with this approach the "threshold" works better. However, I still cannot return the player to walk after it started running.
Meaning: I move my mouse to the Run threshold, my player starts to run, I keep holding down the mouse button and move it around, when I move it back closer to my player, it doesn't slow down, but keeps running. I'd expect that the same mouse distance that made the player run, will return the player to walk.
Concrete example (numbers are random):
Using the settings from your earlier screenshot, I cannot recreate this behaviour. Did you test this behaviour in the current release in the way mentioned above?
The Movement Settings were the same, but I was using a tiny bit older version of AC. Updating AC fixed the issue and it's now working as intended.