Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Movement : MonoBehaviour
- {
- //Movement Variables
- public float Movespeed = 5f;
- public Rigidbody2D rb;
- public Animator Anim;
- // GetAxisRaw
- Vector2 movement;
- //Jump
- public bool Ifjumping;
- void Update()
- {
- //Input
- movement.x = Input.GetAxisRaw("Horizontal");
- movement.y = Input.GetAxisRaw("Vertical");
- //Jump
- if (Input.GetKeyDown(KeyCode.Space))
- {
- Ifjumping = true;
- }
- }
- void FixedUpdate()
- {
- rb.MovePosition(rb.position + movement * Movespeed * Time.fixedDeltaTime);
- if(Ifjumping == true)
- {
- Anim.Play("Jump");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement