[NavMesh] keyboard Input to stick on an object

Hello There,

I have a setup where in can move my player with the right mouse click (unsing nav mesh). I can also click on an enemy and my player go to the closest position from him.

What i try to impletement is a way to ‘stick’ this enemy using a keybaord input.

What i did is just an if statement like this :

     if (Input.GetKeyDown(KeyCode.C) && _enemyTarget)
     {
             _agent.SetDestination(_enemyTarget.transform.position );
     }

my _enemyTarget is setup when i left click on an enemy.

My problem is :

  • The player bump and colide with the enemy (which i don’t want)

Is there a way to put like an offset around the enemy or just tell the setDestination to stop a little before his initial destination ?

Hi Josselin,

For which course project is this?

This topic was automatically closed after 19 hours. New replies are no longer allowed.

Privacy & Terms