Beispiel #1
0
 public void MoveLeft()
 {
     if ((rb.transform.position.x + tempVect.x) > -7.94f)
     {
         MessageLeft.SetActive(false);
         MessageRight.SetActive(false);
         tempVect = new Vector3(-1, 0, 0);
         tempVect = tempVect.normalized * speed * Time.deltaTime / 2.9f;
         rb.MovePosition(rb.transform.position + tempVect);
     }   // Can add more complicated logic here}
     else
     {
         MessageLeft.SetActive(true);
         MessageRight.SetActive(false);
     }
 }
Beispiel #2
0
    public void MoveRight()
    {
        // Can add more complicated logic here

        MessageRight.SetActive(false);
        MessageLeft.SetActive(false);
        if ((rb.transform.position.x + tempVect.x) < -1.2f)
        {
            tempVect = new Vector3(1, 0, 0);
            tempVect = tempVect.normalized * speed * Time.deltaTime / 3;
            rb.MovePosition(rb.transform.position + tempVect);
        }
        else
        {
            MessageLeft.SetActive(false);
            MessageRight.SetActive(true);
        }
    }