Forum rules - please read before posting.

NPC Follow + Keep Out of Player's way

All right... so... waiting to fix the other issue about scrolling, I've one more thing that bothers me! (Sorry Chris!) eheh

And it's the fact that the NPC cannot Keep Out of Player's way, when it started following it...

Let me explain: I've two switchable players, when using one, the other is following and viceversa. All works (almost) good in 2D, but now that I moved in 2.5D is very bothering when the NPC is blocking the way to the player. I've tried with carving the NavMesh method, but it works partially. If it's a narrow street or a corner, it's still messing up everything. The best would be to have the "Keep Out of Player's way" together with "NPC Follow". Of course "Keep Out" is active on my NPC, but has no effect if the NPC is following.

You might argue that if it's following it cannot keep out... but well... If I set the min distance to 2 units, either on following or on keeping out, it should move accordingly. For example if the Player come too closer (i.e. 1 unit), then the NPC should give way, and going back to follow when the distance is 3 units for example.

Why is that not happening? Is some sort of bug or the two things cannot be at the same time? And if not, how can I work-around this issue to make them work as explained above? (i.e. keeping out if distance is under 2 units, following if above 2 units)

Thanks a lot!

Comments

  • NPCs will only attempt to keep out of the Player's way when idle, but this is also limited to NPCs who are not following a character - to avoid conflicts with that system.

    I shall look to see if the two can be used together, but you can "quick hack" this allowance by editing the NPC script's line 109:

    if (followTarget == null && KickStarter.player != null && Vector3.Distance (transform.position, KickStarter.player.transform.position) < minPlayerDistance)
    

    to read:

    if (KickStarter.player != null && Vector3.Distance (transform.position, KickStarter.player.transform.position) < minPlayerDistance)
    
  • Uhmmm I've done it but it's not working... I guess also in this case I'd give up for a more "brutal" option (i.e. getting rid of the rigidbody and let the characters to intersecate).

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.