Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (stopped)
        {
            transform.position = startPos + Vector3.down * emergeMaxDistance;
            return;
        }

        if (GameManager2.IsGameStarted())
        {
            emerging -= Time.deltaTime;
        }
        if (emerging > emergeMaxTime)
        {
            transform.position = startPos + Vector3.down * emergeMaxDistance;
        }
        else
        {
            float trueTime = emerging;
            if (emerging <= -emergeMaxTime)
            {
                if (emerging >= -emergeMaxTime - stopTime)
                {
                    //stand
                    trueTime = -emergeMaxTime;
                }
                else
                {
                    //continue
                    trueTime += stopTime;
                }
            }

            transform.position = startPos + Vector3.down * Mathf.Sin(Mathf.PI / 2f * trueTime / emergeMaxTime) * emergeMaxDistance;
        }

        if (emerging < -emergeFinalTime - stopTime)
        {
            RestartTime();
        }
    }
Ejemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (grab.isGrabbed)
     {
         if (!wasGrabbing)
         {
             wasGrabbing = true;
             if (!GameManager2.IsGameStarted())
             {
                 GameManager2.StartGame();
             }
         }
         Transform hand  = grab.grabbedBy.transform;
         Vector3   angle = hand.rotation.eulerAngles;
         angle.x           -= 315f;
         transform.rotation = Quaternion.Euler(angle);
         transform.position = hand.position;
     }
     else
     {
         rb.velocity = Vector3.zero;
         wasGrabbing = false;
     }
 }