Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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);
- }
- double worldRotation;
- void rotateLeft()
- {
- worldRotation = (worldRotation + 90) % 90;
- }
- if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
- {
- rigid.AddRelativeForce(Vector2.left.Rotate(worldRotation));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement