Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Rigidbody & Ray alternative or optimization

Discussion in 'Physics' started by jordihuertas, Feb 26, 2019.

  1. jordihuertas

    jordihuertas

    Joined:
    Nov 8, 2018
    Posts:
    4
    I am creating an AI that moves around to certain points, but should interact with ais or objects seen.

    The ai should find other ai to comunicate or look for objects on the ground.
    It works with all those next solutions with a low ai number. But when I have +300 ais the fps drops a lot, caused by Physics2D.FixedUpdate or something related with physics.

    How would you deal with this?
    I have tried those solutions:

    Solution 1
    AI:
    • Rigidbody2D Kinematic
    • SphereCollider2D Trigger
    • OnTriggerEnter & Exit Script.
    Objects
    • Rigidbody2D Kinematic
    • SphereCollider2D Trigger
    Solution 2
    AI:
    • Rigidbody2D Kinematic
    • SphereCollider2D Trigger
    • OnTriggerStay Script executed each 120 frames & a Coroutine to simulate OnTriggerExit.
    Objects
    • Rigidbody2D Kinematic
    • SphereCollider2D Trigger
    Solution 3
    AI:
    • No RigidBody
    • SphereCollider2D Trigger
    • Cone of Rays executed each 2 second to detect colliders at certain layers.
    Objects
    • No RigidBody
    • SphereCollider2D Trigger