Sunday, May 12, 2013

A big portion of the upcoming game will be based on sneaking - as such, is important to have a good framework for NPCs to both detect and act on seeing the main character. The first portion has a rough draft finished.



In the first shot, you can see our NPCs all tracking the main character's location (the source of all the blue lines). If the character is in the frustum defined for the particular entity's position and angle, the frustum highlights red. 

In the second shot, the pink indicator is an obstruction ray as cast from the NPC agent's to the main character - if they detect an obstruction, "sight" of the character is lost.

What happens next? Well, there needs to be some sort of pathing system for the NPCs, and there needs to be some sort of dynamic construction of NPC responses. That's down the road :)

And if anyone is wondering? This code will exclude the detector and the detectee in Bepu. It may come in handy :)



    if (Parent.PhysicsEntity.Space.RayCast(new Ray(Parent.PhysicsEntity.Position, positionDir), distance,
        candidate => candidate != Parent.PhysicsEntity.CollisionInformation && candidate != detectableAgents[i].PhysicsEntity.CollisionInformation,
        out Parent.RayCastResult))
    {
        // We have detected an obstruction and cannot detect
        detectableAgents[i].ExitDetected(Parent);
    }


More details to come.
James

No comments:

Post a Comment