Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public float moveSpeed = 5f;
- Rigidbody2D rb;
- public Animator animator;
- Vector2 movement;
- private void Start()
- {
- rb = GetComponent<Rigidbody2D>();
- }
- void Update()
- {
- animator.SetFloat("Horizontal", movement.x);
- animator.SetFloat("Vertical", movement.y);
- animator.SetFloat("Speed", movement.sqrMagnitude);
- }
- private void FixedUpdate()
- {
- rb.velocity = movement;
- }
- public void MoverHaciaDelante()
- {
- movement.y = 1 * moveSpeed;
- }
- public void MoverHaciaAtras()
- {
- movement.y = -1 * moveSpeed;
- }
- public void MoverHaciaDerecha()
- {
- movement.x = 1 * moveSpeed;
- }
- public void MoverHaciaIzquierda()
- {
- movement.x = -1*moveSpeed;
- }
- public void Parar()
- {
- movement = Vector2.zero;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement