- Home /
Tetris rotation issue
Hello, it's my first time doing the game. My problem is that, when I'm trying to rotate my tetromino, it tp all around my map. Someone knew how I can fix that issue? Thanks, a lot
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.LeftArrow)) { transform.position += new Vector3(-1, 0, 0); if (!ValidMove()) transform.position -= new Vector3(-1, 0, 0);
}
else if (Input.GetKeyDown(KeyCode.RightArrow))
{
transform.position += new Vector3(1, 0, 0);
if (!ValidMove())
transform.position -= new Vector3(1, 0, 0);
}
else if (Input.GetKeyDown(KeyCode.UpArrow))
{
//rotate !
transform.RotateAround(transform.TransformPoint(rotationPoint), new Vector3(0,0,0), 90);
if (!ValidMove())
transform.RotateAround(transform.TransformPoint(rotationPoint), new Vector3(0,0,0), -90);
}
if (Time.time - previousTime > (Input.GetKey(KeyCode.DownArrow) ? fallTime / 10 : fallTime))
{
transform.position += new Vector3(0, -1, 0);
if (!ValidMove())
transform.position -= new Vector3(0, -1, 0);
previousTime = Time.time;
}
}
Answer by Dawdlebird · Jun 02, 2021 at 05:49 PM
You're using 'RotateAround', using a zero vector and 90 degrees. This means you are rotating 90 degrees around the world origin. Yes, that would make things jump around. You might want to use transform.Rotate instead.
Your answer

Follow this Question
Related Questions
how to rotate only on the z axis in 2d game,how to rotate only on the z axis 0 Answers
Spawn distance 1 Answer
My enemy gameobjects are merging into one when I want them to follow me in 2D, need some help. 1 Answer
Advertisement.IsReady return false on mobile phone 0 Answers
Confusing with transform.position and transform.localposition in the 2.5d view 1 Answer