コード例 #1
0
    /* VARIANT OF INIT
     * When an echo particle reaches a new color, it stops growing,
     * creates a new particle, and calls resume on the new particle.
     */
    public void resume(EchoParticle previous, GameObject echoMesh, Color newColor)
    {
        transform.position            = previous.transform.position;
        meshObject                    = echoMesh;
        meshObject.transform.position = previous.meshObject.transform.position;
        meshObject.transform.rotation = previous.meshObject.transform.rotation;
        transform.GetComponent <Rigidbody2D>().velocity = previous.GetComponent <Rigidbody2D>().velocity;

        minRad       = previous.collisionRadius;
        radius       = previous.radius;
        maxRad       = previous.maxRad;
        arc          = previous.arc;
        speed        = previous.speed;
        fadeTime     = previous.fadeTime;
        currentColor = newColor;
        // Give echoes parent/child references (for debugging)
        previous.successor = this;
        precedent          = previous;
        // Generic initialization to the mesh object
        mesh = meshObject.GetComponent <MeshFilter>().mesh;
        //Debug.Log(mesh);
        meshRenderer = meshObject.GetComponent <MeshRenderer>();
        meshRenderer.material.SetColor("_TintColor", currentColor);
        initMesh();
    }
コード例 #2
0
    private void split(Color newColor)
    {
        hasSuccessor = true;
        GameObject   newEchoCollider = Instantiate(Scene.get().echoColliderObject);
        GameObject   newEchoMesh     = Instantiate(Scene.get().echoMeshObject);
        EchoParticle newEchoParticle = newEchoCollider.GetComponent <EchoParticle>();

        newEchoParticle.resume(this, newEchoMesh, newColor);
    }
コード例 #3
0
ファイル: Scene.cs プロジェクト: AlmostMatt/Echolocation
 public static void echo(Vector3 echoPos, float echoSpeed = 8f, float range = 15f, float fadeTime = 0.7f, int numP = 64)
 {
     // Force z to -6 so that echos appear in front of other objects
     echoPos.z = -6;
     // TODO: fix bug where particles are sometimes not created or rendered on lower quality settings.
     // This is 100% related to quality settings - particle raycast budget
     // Each echo creates 64 particles that have colliders. if budget is 64 I get 1 echo. if 256 I get 4 echos.
     // Note: this seems to have gone away when I separated echo collider and mesh
     //   This probably means that it no longer considers the collider to be a particle.
     // TODO: fix the phsyics bug that occurs on low quality settings (player collides with something)
     for (int n = 0; n < numP; ++n)
     {
         //int n = 0;
         float        rotation     = n * 2 * Mathf.PI / numP;
         float        arc          = 2 * Mathf.PI / numP;
         GameObject   echoCollider = Instantiate(singleton.echoColliderObject);
         GameObject   echoMesh     = Instantiate(singleton.echoMeshObject);
         EchoParticle echo         = echoCollider.GetComponent <EchoParticle>();
         echo.init(echoPos, echoMesh, rotation, arc, echoSpeed, range, fadeTime);
         get().echos.Add(echo);
     }
 }