Skip to main content
fixed spelling & grammar errors, cleaned up code markdown
Source Link
Pikalek
  • 13.4k
  • 5
  • 49
  • 54

Currently I M Working On 2d Gameam working on a 2D game just like duet game, it is my first game (unityUnity 2D).

when i mWhen I press left key both point are rotatedpoints rotate fine but problem is. But when i m pressI press right point, the points are not rotated?plz help..

So my problem is why do both points are rotated but only in one direction??why??

Code:

    public class TouchControll : MonoBehaviour
    {
      float movespeed = 3;
 
      float angle = 45;

      void Update()
      {
        if (Input.GetKey(KeyCode.LeftArrow))   // when i m press leftarrow both point should be rotate fine  
        {
            transform.Rotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Horizontal") * angle * movespeed);
            Debug.Log("moveleft");
        }

        if (Input.GetKey(KeyCode.RightArrow))  // problem is here when i m press right arrow key both point are not rotated
        {
            transform.Rotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Vertical") * angle * movespeed);
            Debug.Log("moveright");
        }
     }
   }

Output:

create a empty gameobject: enter image description here first circle enter image description here second circle enter image description here

Currently I M Working On 2d Game just like duet game, it is my first game (unity 2D).

when i m press left key both point are rotated fine but problem is when i m press right point are not rotated?plz help..

problem is both points are rotated but only one direction??why??

Code:

    public class TouchControll : MonoBehaviour
    {
      float movespeed = 3;
 
      float angle = 45;

      void Update()
      {
        if (Input.GetKey(KeyCode.LeftArrow))   // when i m press leftarrow both point should be rotate fine  
        {
            transform.Rotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Horizontal") * angle * movespeed);
            Debug.Log("moveleft");
        }

        if (Input.GetKey(KeyCode.RightArrow))  // problem is here when i m press right arrow key both point are not rotated
        {
            transform.Rotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Vertical") * angle * movespeed);
            Debug.Log("moveright");
        }
     }
   }

Output:

create a empty gameobject: enter image description here first circle enter image description here second circle enter image description here

Currently I am working on a 2D game just like duet game, it is my first game (Unity 2D).

When I press left key both points rotate fine. But when I press right, the points are not rotated.

So my problem is why do both points rotated only in one direction

Code:

public class TouchControll : MonoBehaviour
{
  float movespeed = 3;
  float angle = 45;

  void Update()
  {
    if (Input.GetKey(KeyCode.LeftArrow))   // when i m press leftarrow both point should be rotate fine  
    {
        transform.Rotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Horizontal") * angle * movespeed);
        Debug.Log("moveleft");
    }

    if (Input.GetKey(KeyCode.RightArrow))  // problem is here when i m press right arrow key both point are not rotated
    {
        transform.Rotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Vertical") * angle * movespeed);
        Debug.Log("moveright");
    }
  }
}

Output:

create a empty gameobject: enter image description here first circle enter image description here second circle enter image description here

added 68 characters in body
Source Link

Currently I M Working On 2d Game just like duet game, it is my first game (unity 2D).

when i m press left key both point are rotated fine but problem is when i m press right point are not rotated?plz help..

problem is both points are rotated but only one direction??why??

Code:

    public class TouchControll : MonoBehaviour
    {
      float movespeed = 3;

      float angle = 45;

      void Update()
      {
        if (Input.GetKey(KeyCode.LeftArrow))   // when i m press leftarrow both point should be rotate fine  
        {
            transform.Rotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Horizontal") * angle * movespeed);
            Debug.Log("moveleft");
        }

        if (Input.GetKey(KeyCode.RightArrow))  // problem is here when i m press right arrow key both point are not rotated
        {
            transform.Rotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Vertical") * angle * movespeed);
            Debug.Log("moveright");
        }
     }
   }

Output:

create a empty gameobject: enter image description here first circle enter image description here second circle enter image description here

Currently I M Working On 2d Game just like duet game, it is my first game (unity 2D).

when i m press left key both point are rotated fine but problem is when i m press right point are not rotated?plz help..

Code:

    public class TouchControll : MonoBehaviour
    {
      float movespeed = 3;

      float angle = 45;

      void Update()
      {
        if (Input.GetKey(KeyCode.LeftArrow))   // when i m press leftarrow both point should be rotate fine  
        {
            transform.Rotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Horizontal") * angle * movespeed);
            Debug.Log("moveleft");
        }

        if (Input.GetKey(KeyCode.RightArrow))  // problem is here when i m press right arrow key both point are not rotated
        {
            transform.Rotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Vertical") * angle * movespeed);
            Debug.Log("moveright");
        }
     }
   }

Output:

create a empty gameobject: enter image description here first circle enter image description here second circle enter image description here

Currently I M Working On 2d Game just like duet game, it is my first game (unity 2D).

when i m press left key both point are rotated fine but problem is when i m press right point are not rotated?plz help..

problem is both points are rotated but only one direction??why??

Code:

    public class TouchControll : MonoBehaviour
    {
      float movespeed = 3;

      float angle = 45;

      void Update()
      {
        if (Input.GetKey(KeyCode.LeftArrow))   // when i m press leftarrow both point should be rotate fine  
        {
            transform.Rotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Horizontal") * angle * movespeed);
            Debug.Log("moveleft");
        }

        if (Input.GetKey(KeyCode.RightArrow))  // problem is here when i m press right arrow key both point are not rotated
        {
            transform.Rotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Vertical") * angle * movespeed);
            Debug.Log("moveright");
        }
     }
   }

Output:

create a empty gameobject: enter image description here first circle enter image description here second circle enter image description here

deleted 300 characters in body; edited title
Source Link

Two Points Rotating A two point around circleAround Circle?

Currently I M Working On 2d Game just like duet game, it is my first game (unity 2D).

in my gamewhen i m press left key both point are rotated fine but problem is when i m click leftarrow and press right arrrow point are not rotated??plz help..

Code:

float movespeed = 20;

public GameObject[]public balls;

privateclass TouchControll eventController;
: MonoBehaviour
private Rigidbody2D rb;

private Quaternion originalRotation;
{
int movement;

private void Awake()
{
   float rbmovespeed = GetComponent<Rigidbody2D>();
}3;

private void Start()
{
   originalRotation =float rb.transform.rotation;
}

privateangle void= Update()45;
{
    Rotate(180);
}

public  void RotateUpdate(float angle)
{
   float r = angle * Time.deltaTime;{
     
    if (Input.GetKey(KeyCode.LeftArrow))   // when i m press leftarrow both point should be rotate fine  
        {
            transform.TranslateRotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Horizontal") * angle * movespeed);
            Debug.Log("moveleft");
        } 

    
     if (Input.GetKey(KeyCode.RightArrow))  // problem is here when i m press right arrow key both point are not rotated
        {
            transform.TranslateRotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Vertical") * angle * movespeed);
    }
    rb.transform.Rotate(Vector3.forward * r * Debug.Log(float)movement"moveright");
    //rb.transform.rotation = Quaternion.Lerp(rb.transform.rotation, originalRotation, Time.deltaTime}
 * 5f);   }
   }

ReferancesOutput: enter image description here enter image description here enter image description here

enter image description herecreate a empty gameobject: enter image description here first circle enter image description here second circle enter image description here

Rotating A two point around circle?

Currently I M Working On 2d Game

in my game problem is when i m click leftarrow and right arrrow point are not rotated??

Code:

float movespeed = 20;

public GameObject[] balls;

private TouchControll eventController;

private Rigidbody2D rb;

private Quaternion originalRotation;

int movement;

private void Awake()
{
    rb = GetComponent<Rigidbody2D>();
}

private void Start()
{
   originalRotation = rb.transform.rotation;
}

private void Update()
{
    Rotate(180);
}

public void Rotate(float angle)
{
   float r = angle * Time.deltaTime;
     
   if (Input.GetKey(KeyCode.LeftArrow))
  {
     transform.Translate(Vector3.forward * Time.deltaTime * Input.GetAxis("Horizontal") * angle);
     Debug.Log("moveleft");
   }
    
    if (Input.GetKey(KeyCode.RightArrow))
    {
        transform.Translate(Vector3.forward * Time.deltaTime Input.GetAxis("Vertical") * angle);
    }
    rb.transform.Rotate(Vector3.forward * r * (float)movement);
    //rb.transform.rotation = Quaternion.Lerp(rb.transform.rotation, originalRotation, Time.deltaTime * 5f);
}

Referances: enter image description here enter image description here enter image description here

enter image description here

Two Points Rotating Around Circle?

Currently I M Working On 2d Game just like duet game, it is my first game (unity 2D).

when i m press left key both point are rotated fine but problem is when i m press right point are not rotated?plz help..

Code:

    public class TouchControll : MonoBehaviour
    {
      float movespeed = 3;

      float angle = 45;

      void Update()
      {
        if (Input.GetKey(KeyCode.LeftArrow))   // when i m press leftarrow both point should be rotate fine  
        {
            transform.Rotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Horizontal") * angle * movespeed);
            Debug.Log("moveleft");
        } 

        if (Input.GetKey(KeyCode.RightArrow))  // problem is here when i m press right arrow key both point are not rotated
        {
            transform.Rotate(Vector3.forward * Time.deltaTime * Input.GetAxis("Vertical") * angle * movespeed);
            Debug.Log("moveright");
        }
     }
   }

Output:

create a empty gameobject: enter image description here first circle enter image description here second circle enter image description here

Source Link
Loading