I'm trying to figure out how I can make the input which looks like this :
// Checks if player is pressing movement keys, if is applies force to specified direction
if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
{
//rigid.AddForce(new Vector2(-speed * Time.deltaTime, 0));
rigid.AddRelativeForce(Vector2.left);
}
if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
{
//rigid.AddForce(new Vector2(speed * Time.deltaTime, 0));
rigid.AddRelativeForce(Vector2.right);
}
if (Input.GetKey(KeyCode.UpArrow) && groundCheck.isGrounded == false || Input.GetKey(KeyCode.W) && groundCheck.isGrounded == false || Input.GetKey(KeyCode.Space) && groundCheck.isGrounded == false)
{
groundCheck.isGrounded = false;
//rigid.AddRelativeForce(new Vector2(0, jumpPower));
rigid.velocity = new Vector2(rigid.velocity.x, jumpPower);
}
Always move according to the maps rotation.
So, even if the map were to rotate the player doesn't get inverted inputs (player is children of map, so it rotates too) :
Right now A is always to left, according to the players position, but if the player would rotate 90 degrees the input would be wrong, Left would be up/down, but I want it to still be left.
Here's a picture example : (Sorry for the horrible painting, I blame mouse :> )
I do want the physics in the world to not change when I rotate the world.
So if the player is rotated 90 degrees it should fall to the side instead of down. :D
AddForce()
rather thanAddRelativeForce()
. \$\endgroup\$