News Forums RAIN General Discussion and Troubleshooting Player movement

This topic contains 4 replies, has 3 voices, and was last updated by  prime 8 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #9609

    marooned
    Participant

    Hello,
    I recently started using RAIN for my RPG which is working great for my NPCs. However I’m also trying to implement path finding for my player character. I’m trying to achieve Diablo 3 style movement where the player can either click to path find or hold down the mouse button to control the character directly. Directly controlling the character should not path find and always follow the mouse.

    I am having two issues:

    1. When the player clicks off the nav mesh I can’t path find to that point. I haven’t been able to figure out a way of finding the nearest point on the nav mesh. The built in Unity nav mesh has a SamplePosition function to get the closest point but I can’t find anything similar in RAIN. I attempted to build a function myself but it seems I need to use polybuckets from the navigation graph which isn’t accessible.

    2. I’m not sure of the best way to directly control the character. I tried doing this by using a custom motor and setting the move target to just in front of the character in the direction of the mouse. This works fine but the character stops completely when hitting a wall instead of sliding along it. I think I’d have to find the edge in front of the character and set the direction and speed accordingly. I guess I could achieve this kind of movement without RAIN but I need to keep the player on the nav mesh so pathfinding will work.

    I’d appreciate any advice.

    Thanks

    #9624

    prime
    Keymaster

    1) Let me give some thought to the best way to help with that. This is an area we are considering changes to, so I don’t want to make the poly buckets public just yet. However, we can look into changing the closest point on mesh method to return mesh points when querying from off-mesh points. Even that isn’t totally sufficient, since the returned point may be inaccessible (no path available).

    2) If you are going to directly control the character, you may be best off deactivating the AI and just using your own custom setup for that. AI movement isn’t really the same as normal player-based movement so you may be fighting the system a bit. If what you want is “click on a spot and then move there”, that’s easier. Just project the click to a surface and set the intersection as a move target.

    #9697

    marooned
    Participant

    Thanks Prime. I was pretty close to finding a solution today but it doesn’t work all the time. I got the edges from the graph and found the closest edge point. It works in some cases but doesn’t always produce a valid point on the mesh so the move action doesn’t work, or sometimes it does move and the character gets stuck. It’s not a huge problem though; I can just modify the motor and use the Unity built in nav mesh for now and look at this again later. I’m interested to see any changes you make in this area. Thanks very much for the help.

    #33956

    Makarios
    Participant

    I know this is a slightly older post, but I’m working on a game with a similar setup of point and click movement.

    Are the changes you were mentioning active now? and if so can you point me in that direction if its in a tutorial or documentation that I haven’t seen?

    #33988

    prime
    Keymaster

    RAIN now supports movement to points off the navmesh. The pathfinding system attempts to find the nearest point on the navmesh to path to, then creates a path either to that nearest point or all the way to the target depending on whether Allow Off Graph Movement is enabled.

    If you are using point and click movement, just give your AI the destination point as its move target and everything will work fine.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.