Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- public class PlayerMove : MonoBehaviour
- {
- public Rigidbody2D rgb;
- public SpriteRenderer spriteRenderer;
- private float hor;
- private float ver;
- public float speed = 2f;
- void Update()
- {
- hor = Input.GetAxisRaw("Horizontal");
- ver = Input.GetAxisRaw("Vertical");
- rgb.velocity = new Vector2(hor * speed, ver * speed);
- if (hor == -1)
- {
- spriteRenderer.flipX = true;
- }
- else if (hor == 1)
- {
- spriteRenderer.flipX = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement