Beispiel #1
0
 //updates every frame
 private void Update()
 {
     SeekTarget();
     transform.LookAt(transform.position + body.velocity);
     sprite.SetRotation(transform.rotation.eulerAngles.y);
     body.velocity = velocity;
     if (body.velocity.magnitude > 0.1)
     {
         transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(body.velocity), Time.deltaTime * 0.01f);
     }
 }
    //applies movement effects
    void Update()
    {
        transform.LookAt(transform.position + body.velocity);
        //Debug.Log ("ROTATION: " + transform.rotation.x + ", " + transform.rotation.y + ", " + transform.rotation.z);
        if (twoD)
        {
            sprite.SetRotation(transform.rotation.eulerAngles.y);
        }

        if (guided && seeking)
        {
            ExclusiveSeeking();
        }

        if (guided)
        {
            GuideProjectile();
        }

        if (seeking && !targetFound)
        {
            FindTarget();
        }
        if (seeking)
        {
            SeekTarget();
        }

        if (evaporating)
        {
            lifetime -= 2 * Time.deltaTime;
        }
        else
        {
            lifetime -= Time.deltaTime;
        }

        if (lifetime <= 0f)
        {
            Destroy(gameObject);
        }

        body.velocity = velocity;

        if (body.velocity.magnitude > 0.1)
        {
            transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(body.velocity), Time.deltaTime * 0.01f);
        }
    }
    //controls the projectiles movement
    void Update()
    {
        transform.LookAt(transform.position + body.velocity);
        sprite.SetRotation(transform.rotation.eulerAngles.y);

        lifetime -= Time.deltaTime;
        if (lifetime <= 0f)
        {
            Destroy(gameObject);
        }

        body.velocity = velocity;

        if (body.velocity.magnitude > 0.1)
        {
            transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(body.velocity), Time.deltaTime * 0.01f);
        }
    }