Esempio n. 1
0
    void movementManagement()
    {
        //update `angle_accel` with `angle_var
        if (is_mobile)
        {
            if (on_myeline)
            {
                this.GetComponent <Rigidbody2D>().velocity = Vector2.zero;
            }
            else
            {
                int   angle_force = 3;
                float lambda      = 0.5f;
                float angle_delta = RandomGaussianGenerator.GenerateNormalRandom(0, 10.0f, -angle_force, angle_force);

                angle_accel = lambda * angle_accel + (1 - lambda) * angle_delta;
                this.speed  = this.speed.Rotate(angle_accel);
                this.GetComponent <Rigidbody2D>().velocity = this.speed;
            }
        }
        else
        {
            this.GetComponent <Rigidbody2D>().velocity = Vector2.zero;
        }
    }
Esempio n. 2
0
    void movementManagement()
    {
        if (shot)
        {
            transform.position += direction.normalized * speed;
        }
        else
        {
            float freq_small   = 3.0f;
            float radius_small = 0.001f;

            float freq_big   = 1.0f;
            float radius_big = 0.01f;

            transform.position += new Vector3(Mathf.Cos(timer * freq_small * 1.30289f + seed),
                                              Mathf.Sin(timer * freq_small * 1.02308f + seed),
                                              0) * radius_small +
                                  new Vector3(Mathf.Cos(timer * freq_big * 1.4329f + seed),
                                              Mathf.Sin(timer * freq_big * 1.0389f + seed),
                                              0) * radius_big;


            //update `angle_accel` with `angle_var
            int   angle_force = 3;
            float lambda      = 0.5f;
            float angle_delta = RandomGaussianGenerator.GenerateNormalRandom(0, 10.0f, -angle_force, angle_force);

            angle_accel      = lambda * angle_accel + (1 - lambda) * angle_delta;
            this.speedVector = this.speedVector.Rotate(angle_accel);
            this.GetComponent <Rigidbody2D>().velocity = this.speedVector;
        }
    }