示例#1
0
文件: closing.cs 项目: schreck/sg
    // Update is called once per frame
    void Update()
    {
        if (tracking)
        {
            xt = target.transform.position - transform.position;
            vt = target.GetComponent <Motive>().v - v;
            Vector3 v_radial  = Vector3.Project(vt, xt.normalized) - 2f * xt.normalized;
            Vector3 v_tangent = vt - v_radial;

            // had rad_ratio means radial burn off
            // low mean closing
            rad_ratio = v_radial.magnitude / (v_tangent.magnitude + v_radial.magnitude);
            Vector3 a_radial  = rad_ratio * a_max * xt.normalized;
            Vector3 a_tangent = (1 - rad_ratio) * a_max * v_tangent.normalized;
            Vector3 a         = a_radial + a_tangent;
            transform.rotation = Quaternion.LookRotation(a, transform.rotation * Vector3.up);
            v += a * Time.deltaTime;
            if (xt.magnitude < 2)
            {
                tracking = false;
                trail.End(v - 2f * a, transform.position);
                GameObject exploder = Instantiate(explorer_prefab, new Vector3(0, 0, 0), Quaternion.identity);
                exploder.transform.position = transform.position;
                gameObject.GetComponent <Renderer>().enabled = false;
            }
            else
            {
                trail.Push(v - 2f * a, transform.position);
            }
        }
        transform.position += v * Time.deltaTime;
    }
示例#2
0
文件: Motive.cs 项目: schreck/sg
 // Update is called once per frame
 void Update()
 {
     if (Time.time - start_time < 15f)
     {
         a += (.02f) * Random.onUnitSphere;
         v += a * Time.deltaTime;
         trail.Push(v - 4f * a, transform.position);
     }
     else
     {
         trail.End(v - 4f * a, transform.position);
     }
     transform.position += v * Time.deltaTime;
 }