Question by
oliverlien08 · Feb 16, 2020 at 01:57 PM ·
jumpgroundedground detection
I need help with grounding.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerControls : MonoBehaviour
{
public Rigidbody2D rb;
public Transform groundCheck;
public float groundCheckRadius;
public LayerMask whatIsGround;
private bool onGround;
void FixedUpdate()
{
onGround = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);
}
void Start()
{
}
void Update()
{
rb.velocity = new Vector2(5, rb.velocity.y);
; if (Input.GetMouseButtonDown(0)
){
rb.velocity = new Vector2(rb.velocity.x, 7);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Checking if the player jumps while not grounded 0 Answers
How can i add a groundCheck to my script? 1 Answer
Able to jump in air? (Reward) 1 Answer
Ground Script explanation 1 Answer