- Home /
Player Movement Question in 2D
How can I move a player along an elliptical orbit on the borders of the 16:9 aspect ratio frame using just the left right arrow keys.
Forgive me I am a total newbie. Just been messing around with unity for about a week.
Is there an API for this movement? I want to shoot for the center, but at this moment I am having trouble just setting the boundaries of my player movement. at the most basic so far:
float _speed = 5.0f;
transform.position = new Vector2(0, -4.33f);
float horizontalInput = Input.GetAxis("Horizontal");
transform.Translate (Vector2.right _speed horizontalInput * Time.deltaTime);
if (transform.position.x > 8.6f) { transform.position = new Vector2(8.6f, transform.position.y); } else if (transform.position.x < -8.6f) { transform.position = new Vector2(-8.6f, transform.position.y); }
player stays within the lower bound of the screen. Cant seem to make him travel Up the right side when the player reaches the right boundary on the x-axis.
My example of the player movement would be like Gyrus.