Home Forums General Discussion Detecting Collisions on a Capsule Collider

This topic contains 2 replies, has 2 voices, and was last updated by  gstock 3 weeks, 4 days ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #6185



    I’m trying to make a character AI that can receive a hit from a bullet and act based on it. I thought about doing it with sensors, but given that those have a spherical shape it won’t work for me. Any ideas in how I could use a “Capsule” sensor?

    Am I taking the wrong approach by trying to use sensors?




    A couple of thoughts:

    1) if you do need Sensors, you could create a custom sensor that manages the visibility test itself. You would probably derive from VisualSensor and just override TestVisibility. You could then use a test that compared an object to the capsule.

    2) You probably don’t want to use a sensor for this. If you are actually using physics to detect bullet collisions, then let the physics collision happen and trigger AI behavior in your physics event handler. If you aren’t using physics and essentially have “fake” bullets, then just trigger the AI behavior wherever you determine that a bullet hit has happened.

    In FPSControl, for example, the firing weapon does a raycast test and then sends a damage event to the object being hit. AI info is updated in the damage event.



    Thanks @prime!

    In case someone finds this post useful, I added a Capsule Collider to my GameObject and added this script to it:

    function Start () {
    airig = gameObject.GetComponentInChildren(AIRig);

    function OnCollisionEnter(collision : Collision) {

    airig.AI.WorkingMemory.SetItem(“gotHit”, true);

    Then evaluated “gotHit” from a Constraint on the Behavior Editor

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.