Navmesh agent stuck to dead enemy after picking up their item

sdhains

New member
This specific chain of events is causing Bug using UCC/BD in unity 2018.3.f1.

Bug description: Navmesh agent gets stuck to enemy they kill and retrieve item from, after activating ability.

This specific sequence of events produces the bug:

1. Enemy dies drops an Item Pickup
2. Player picks up the item
3. Ability is automatically activated due to item being acquired (see below for code)
4. Player seeks new destination (BD Seek)

The agent gets stuck here, standing over the enemy they just killed.

BD thinks the agent is moving towards its new agent. The agent agent is actually moving towards the transform of the enemy they just killed. If I manually drag the enemy in the viewport to where the agent is supposed to go, the agent follows and the task completes.

Why would agent be getting stuck to the corpse that it just picked an item off?

To make matters more confusing, the issue depends on the automatic activating of the ability (step 3.). If i turn off the ability, the character is able to pick up the item from the enemy and move onward - no problem.


The ability is extremely simple, it looks like this:

Code:
public override bool IsConcurrent => true;

    // Start is called before the first frame update
    public override bool CanStartAbility()
    {
        var inventory = GetComponent<Inventory>();
        if (inventory == null) return false;

        foreach (var item in inventory.GetAllItems())
        {
            if (item.name == "Trauma") return true;
        }

        return false;
    }

    protected override void AbilityStarted()
    {
        GetComponent<Animator>().SetBool("Traumatized", true);
        base.AbilityStarted();
    }

protected override void AbilityStopped(bool force)
{
    GetComponent<Animator>().SetBool("Traumatized", false);
    base.AbilityStopped(force);
}

thankyou
 
Last edited:
This is extremely tough to debug since there are a lot of factors, but based on your ability it doesn't look like you are changing the movement direction at all. My best guess is that the traumatized variable is preventing the animator from playing a walking animation which will then prevent the character from moving.
 
This is extremely tough to debug since there are a lot of factors, but based on your ability it doesn't look like you are changing the movement direction at all. My best guess is that the traumatized variable is preventing the animator from playing a walking animation which will then prevent the character from moving.

I suspected. Thanks for trying.

I'm setting the movement stuff all in BD. The ability is purely a state management thing. So that I can trigger behaviors in BD and in the animator based on whether or not the character is holding any "Trauma" items.

It isn't the Animator variable because I can comment those lines out and it makes no difference. I've given up for now. When I have a chance I'll probably just try and implement this manually with some Monobehavior scripts.
 
Top