Question by
boier96 · Sep 28, 2020 at 10:52 AM ·
gravityground detection
Hi there need help to fix something,How do i make a if ground checked
,Hey so i have this script that changes the gravity but i would like to make it so it cant change in mid air but i couldn't get it to work so if someone knows how to then please tell man. here is the script
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class gravity : MonoBehaviour {
private Rigidbody2D rb;
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
if
{
if (Input.GetKeyDown(KeyCode.F))
{
rb.gravityScale *= -1;
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Changing gravity at the click of a button... 5 Answers
simple roll a ball game - ball slips threw ground 1 Answer
Spheres change form on collision 0 Answers
How to make GameObject fall with the same gravity while using AddForce() 1 Answer
[Kudan AR] (Markerless) Augmented Reality and Rigidbodies 0 Answers