Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlayerController : MonoBehaviour
- {
- public float speed;
- public float JumpForce;
- private float moveInput;
- private Rigidbody2D rb;
- private bool isGrounded;
- public Transform groundCheck;
- public float checkRadius;
- public LayerMask whatisGround;
- // Use this for initialization
- void Start () {
- extraJumps = extraJumpvalie;
- rb = GetComponent<Rigidbody2D>();
- }
- private void FixedUpdate()
- {
- isGrounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatisGround);
- moveInput = Input.GetAxis("Horizontal");
- rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);
- }
- // Update is called once per frame
- void Update ()
- {
- if(isGrounded == true){
- extraJumps = extraJumpvalue;
- }
- if (Input.GetKeyDown(KeyCode.Space) && extraJumps > 0)
- {
- rb.velocity = new Vector2(rb.velocity.x, jumpForce);
- extraJumps;
- } else if(Input.GetKeyDown(KeyCode.Space) && extraJumps == 0)
- {
- RenderBuffer.velocity = Vector2.up * jumpForce;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement