Ejemplo n.º 1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        foreach (Movers m in movers)
        {
            Rigidbody body  = m.body;
            Vector3   force = a.Attract(body); // Apply the attraction from the Attractor on each Mover object

            m.ApplyForce(force);
            m.Update();
        }

        a.Update();
        a.CheckEdges();
    }
    // Update is called once per frame
    void Update()
    {
        // octopi
        foreach (chapter1Creature o in octopi)
        {
            o.move();
            o.checkEdges();
        }
        //wisps
        foreach (Mover2_7 m in movers)
        {
            Rigidbody body  = m.body;
            Vector3   force = a.Attract(body); // Apply the attraction from the Attractor on each Mover object

            m.ApplyForce(force);
            m.Update();
        }
        a.update();
        //worms
        foreach (baton w in worms)
        {
            w.update();
        }

        //fish
        foreach (Movers m in fish)
        {
            Rigidbody body  = m.body;
            Vector3   force = fishLead.Attract(body); // Apply the attraction from the Attractor on each Mover object

            m.ApplyForce(force);
            m.Update();
        }

        fishLead.Update();
        fishLead.CheckEdges();

        //randomFish
        foreach (randomFish fish in fishR)
        {
            fish.Update();
            fish.CheckEdges();
        }
        //squid
        foreach (oscillator o in oscillate)
        {
            o.x      = Mathf.Sin(o.angle.x) * o.amplitude.x;
            o.y      = Mathf.Sin(o.angle.y) * o.amplitude.y;
            o.z      = Mathf.Sin(o.angle.z) * o.amplitude.z;
            o.angle += o.velocity;
            o.lineRender.SetPosition(1, o.oGameObject.transform.position);
            o.lineRender.SetPosition(0, randomFish2.body.transform.position);
            o.oGameObject.transform.transform.Translate(new Vector3(o.x, o.y, o.z) * Time.deltaTime);

            Vector3 difference = randomFish2.body.transform.position - o.oGameObject.transform.position;
            float   m          = difference.magnitude;
            if (m <= 1f)
            {
                o.oGameObject.transform.transform.Translate(new Vector3(o.x, o.y, o.z) * Time.deltaTime);
            }
            else
            {
                //o.angle -= o.velocity;
                o.oGameObject.transform.transform.Translate(new Vector3(o.x, o.y, o.z) * Time.deltaTime);
            }
            randomFish2.Update();
            randomFish2.CheckEdges();
        }
    }