Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ~~~~~~~~~~~~~~~~~~ PRIMEIRA FORMA:~~~~~~~~~~~~~~~~
- public float maxSpeed = 10;
- //andando para esquerda
- if (Input.GetKey("left") || Input.GetKey ("a"))
- {
- transform.position -= Vector3.right * maxSpeed * Time.deltaTime;
- }
- //andando para direita
- if (Input.GetKey ("right") || Input.GetKey ("d"))
- {
- transform.position += Vector3.right * maxSpeed * Time.deltaTime;
- }
- ~~~~~~~~~~~~~~~~~~~~~~~~SEGUNDA FORMA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- //esquerda
- if (Input.GetAxisRaw ("Horizontal") > 0)
- {
- transform.Translate (Vector2.right * maxSpeed * Time.deltaTime);
- }
- //direita
- if (Input.GetAxisRaw ("Horizontal") < 0)
- {
- transform.Translate (-Vector2.right * maxSpeed * Time.deltaTime);
- }~
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TERCEIRA FORMA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- float move = Input.GetAxis ("Horizontal");
- rigidbody2D.velocity = new Vector2 (move * maxSpeed, rigidbody2D.velocity.y);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement