I used the event system to create a makeshift controller for the player combatant that I'm pretty happy with so far, except that it always takes 3 clicks after startup before unity registers the mouse input. It doesn't matter for how long the game sits after startup--three mouse clicks appears to be the magic number before the player combatant will start to move around. I've overridden the standard ORK controller by setting it to Navmesh and assigning it not to recognize any layers, and used a simple control map to run a Global Event after pressing the mouse button in the field under all conditions. Is there a better way?
  • Using the built-in Mouse player controller with the Nav Mesh Agent move type is not an option?

    Hard to tell why you need 3 clicks when starting - might be due to something blocking the mouse click.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • "Using the built-in Mouse player controller with the Nav Mesh Agent move type is not an option?"

    I could never tweak the Unity NavMeshAgent in a way that made movement seem natural. Besides, ORK events are a much more powerful tool. I can force my combatants to turn before they begin moving and fine tune their acceleration in ways the built-in Nav agent doesn't allow, and I can also directly apply things like movement costs and such. Plus, using Navmesh via an event still provides the same pathfinding, so it just seems like the better method. My settings under player controls to prevent the two from conflicting are:

    -Player Controls; Control Type: Mouse

    -Layer Mask: Nothing

    -Move Type: Nav Mesh Agent


    "Hard to tell why you need 3 clicks when starting - might be due to something blocking the mouse click."

    Blocking how? What do you think might prevent the first two clicks from registering?
  • Since you're moving via events, I'd recommend setting the player control type to None instead.

    Blocking could come in 2 different ways - either the actual input is consumed (e.g. the click accepting a dialogue, which consumes the input) or the raycast from the click to determine the position is blocked by some collider or UI, resulting in an invalid NavMesh position (or not hitting anything at all).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • "Blocking could come in 2 different ways - either the actual input is consumed (e.g. the click accepting a dialogue, which consumes the input) or the raycast from the click to determine the position is blocked by some collider or UI, resulting in an invalid NavMesh position (or not hitting anything at all)."

    It's not an issue of the clicked position. I can click anywhere on the screen and it always takes the same amount of tries before placing a marker to which the player combatant then moves. I've also temporarily set the way-point prefab to a visible object so that I can see where it spawns. Once it starts working, after the three clicks, I can always get it to spawn and the player will re-target if the way-point/prefab is off the Navmesh.

    "Since you're moving via events, I'd recommend setting the player control type to None instead."

    Would that cause an issue when clicking on the UI or on an intractable game object? Is the Player Controller setting strictly for controlling movement over terrain? One feature that I've been unable to get working through an event is to have it determine what the mouse cursor is hovering over prior to setting a way-point. It ignores checks intended to test the type of layer its hovering over, and it ignores the UI. I'm guessing this issue is on account of my setting the raycast from screen to cursor, so it simply doesn't detect what's underneath.
  • Hm, strange - since you're using such a custom setup, I'd need a test project to investigate where the first clicks vanish to ...

    Using a None player controller shouldn't cause any issues, rather prevent them since you're not actually using the built-in control.
    I'd need to know how you're performing those checks to give advise :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • "Using a None player controller shouldn't cause any issues, rather prevent them since you're not actually using the built-in control.
    I'd need to know how you're performing those checks to give advise :)"

    I went back and took a second look at the check nodes at the beginning of the event, and it's pretty obvious why they don't work. They're just 'Raycast to Variable' nodes. I put different layer masks on each of them, but I also set the raycast to use the mouse position from the screen as an origin point. Obviously, the mouse cursor doesn't actually rest on a layer, it just hovers over and selects them, so the raycast never detects the layer underneath. Does a 'Vector 3" variable rest on a layer? Mayber I could check against that after it's created. Better yet, is it possible to change a game variable depending on what the mouse is hovering over? That would be an easy way to update the visible cursor to show default interactions.

    "Hm, strange - since you're using such a custom setup, I'd need a test project to investigate where the first clicks vanish to ..."

    I'd be more than happy to send you a copy of my project, apart from a lingering concern of potentially placing it in jeopardy by transferring licensed third party assets without permission. Would you be able to test the event itself if I sent you that alone?
  • The Raycast To Variable node stores the position that was hit by the raycast based on the node's setup (and if something was hit). I.e. the position that was hit is afterwards available in the game variable you've used to e.g. spawn your cursor there.
    There's no layer attached to that, but the raycast uses the layers you've defined and will hit only game objects on these layers.

    I'd at least need your ORK project asset (usually at Assets/ORK Framework/ORKProject.asset) in combination with your event assets :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.