Search Unity

[Open-source] Simple Unity3d Vision system

Discussion in 'Scripting' started by golergka, Dec 7, 2012.

  1. golergka

    golergka

    Joined:
    Mar 15, 2012
    Posts:
    30
    Vision is simple system to realize a spherical AI vision in your projects. This is how it works:

    • Create single gameObject with VisibleGrid in the scene for the system to work. (It serves as a cache).
    • Put Visible component on the gameObjects that you want to be visible.
    • Use IVisibleListener interface on other components of this object to know when you're being seen.
    • Put Vision component on the gameObjects taht you want to see.
    • Use IVisionListener interface on other components of this object to know what you see.
    • Or just use VisiblesInSight().

    I've used the current version for simple RTS RPG mechanics, works perfectly with big amount of objects. I've come to conclusiton that manual sphere-checking is more comfortable than using trigger colliders: you often already have a rigidbody collider on you gameObject, so you have to create another sub-object with a delegate, etc, etc. Plus, this version is easily convertible to situations where Unity physics couldn't be used (deterministic RTS engine, for example).

    Future plans:

    • Optimizaitons where neccessary.
    • Cone-shaped vision along the forward vector of object's transform.
    • Raycasting.

    Get source here:
    https://github.com/golergka/Vision/
    Or download Unity package:
    https://github.com/downloads/golergka/Vision/Vision.unitypackage