[Released] PathBerserker2d - 360° platformer pathfinding

Thank you for reply, I will try your solution.

Hello, your solution works perfectly! Now I have another little problem… There was an option to disable rotation on corners? I don’t need the rotation on stairs in some agents.

May be the solution are to put a link on corners??

Just remove the AdjustRotation script from your NavAgent. Its what adjustes the NavAgents rotation to be perpendicular to the current segment normal.

That was my first try with no luck, only works when I insert links on corners.

Okay. Sorry that was an oversight of mine. In the next release I’ll add a checkbox on the NavAgent to control corner rotation. For now, you can just attach this script to the NavAgent and the rotation should stop.

using PathBerserker2d;
using UnityEngine;

public class CornerRotationSkipper : MonoBehaviour
{
    [SerializeField]
    NavAgent agent;

    void Start()
    {
        agent.OnStartLinkTraversal += Agent_OnStartLinkTraversal;
    }

    private void Agent_OnStartLinkTraversal(NavAgent agent)
    {
        if (agent.CurrentLinkType == "corner")
            agent.CompleteLinkTraversal();
    }
}

Thank you, it works.

Hi, just got the pathfinding asset and it works. Thanks a lot!
I am wondering is there an agent width parameter like the navmesh in 3D?
Besides, any solution for the flying agent in current version?

There is no width parameter. The pathfing system models a NavAgent as a walking stick. This was a design decision I made, because width in 2d games can be interpreted in different ways. For example, slopes may require an agent to clip into the ground or rotated to align with the ground. A width check would not allow such a character to enter a slope.

Flying agents are not currently supported. Flying requires different pathfinding data and algorithms. It wouldn’t be an addition to the current system, but an almost completely new and different system. I need to evaluated whetever this would be worth the developement time.

Thanks for your reply!

In the case of agent width, is there a possible feature update to make us able to shorten the length of the final segment when it is not close? This could in some sense solve the agent width problem without affecting the slope mechanics i think. And also different agent could use different pre-baked path which would give a limited degree of freedom in designing the agent’s width.
6678913--765394--upload_2021-1-2_12-5-29.png

For the flying agent, I guess current solution is turn to the traditional 2d top-down pathfinding method. Since it is already included in many pathfinding asset, would you still consider to add this function if there are demand? Really hope your pathfinding asset could be “the” asset for all 2d platform game.

Do you mean, update the check for if the agent reached is goal, to consider an agents width?

Yeah, I’d like to do that.

Hello, I updated to the last version, added the new “transform base movement” component but my NavAgents not move.

I debug the NavAgent and have the HasValidPosition to false and “currentMappedPosition.surface” to null. I think thats the reason of the problem by I don’t know why this happend after update.

Best regards.

More information:
I make a simple tile map to explain the problem.
In first image the cube to the left don’t walk to the image of the right.

In the second image, I have erased the ceiling, rebaked and works perfect.

The cube height was 0.1, I was tray with 1 and 2.

Any idea what I’m making wrong?

Again… more information. it works if I make a wall… You could see in the las image.



I’m very sorry you experience this issue. There is a bug-fix coming in the next update that should hopefully fix your problem. The update is already submitted and should be live in 1-2 days. (Depends on Unity really)

If you like to get it earlier, write me a PM with invoice number and I’ll send it to you early.

Ok, thank you, I could wait until release.

Hello!
I am currently using two navsurface components attached to two different composite colliders (one for solid platform and one for one way platform). However, when i place a random walk agent to the scene, it seems that it could only move along either the solid platform surface or the one-way platform surface.
Instead of adding links to the adjacent points, is there any other way in combining the two tpyes of navsurface?

Sorry, that is not possible. Internally segments in a NavSurface are represented as a quasi linked list. Branching is not possible. Every segment can only connect to two other segments at each of its end points.

You have to use links to connect them. There is no otherway. Internally, the connection between two segments is modeled as a link anyway. A link of type “corner” to be exact.

You probably don’t want your agent traversing this link by jumping right? You can set the link type to “teleport” and the agent won’t jump. If the link points are close enough the teleportation won’t be visible.

Hi, here is a bug report related to the TransformBasedMovment class.
Following is an example, it seems that part of the code failed in moving platform situation, which lead to abnormal agent motion when jumping outside a moving platform (I guess vice versa since direction * timeOnLink * jumpSpeed doesn’t consider the moving end point)

You are right. Good catch!
agent.CurrentLinkStart indeed changes with a moving platform. I’m going to add your idea of storing the link start in a variable to keep it constant.

I’m wondering if I should also make the jump react to a moving goal position. Right now, an Agent can miss a jump, if the goal moves to much. But making a jump always land on its target no matter how fast it moves, can make the jump look reality bending wierd. Thoughts?

Since to achieve moving goal position requires the prediction of moving path and set the agent jump in advance, finding a sophisticate solution requires a lot of extra work besides the path finding method itself. Currently, i am adding restrictions on the validation of the jump link and making the agent jump in the frame of moving goal. Although this kind of tricks aren’t really solve the question itself but for me it works and acceptable.

For the restriction of in the jump link, in current version, the length of the link seems to be the only condition to check whether this edge is valid in the graph of path finding. What i am doing is adding an ITraversable interface to the moving platform and make it communicate with the navlink when the moving platform becomes the goal of the jump. The platform becomes traversable when the motion of it is under certain condition (I set stoped in my project). I think it is also good to add similar interface to your asset since it give extra control of the nav link and no extra work for you to decide when the moving goal is traversable.
6739180--776443--upload_2021-1-19_14-11-11.png

Last, I really wish you could add a component that could combine all the navsurfaces under its child objects. (raised in my previous post) Adding a tiny navlink to every navsurfaces addjacent point is really frustrated. If two segement from different navsurface are close to each other, just make me able to set them linked automaticly plz.

Works only with tiles? or I can use it without a grid?

Works with every 2d collider. I guess I gotta add some non-tilemap screenshots to the storefront :smile:.