unity how to make jump script
C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class jump : MonoBehaviour
{
public float jumpHeight = 7f;
public bool isGrounded;
public float NumberJumps = 0f;
public float MaxJumps = 2;
private Rigidbody rb;
void Start()
{
rb = GetComponent<Rigidbody>();
}
void Update()
{
if (NumberJumps > MaxJumps - 1)
{
isGrounded = false;
}
if (isGrounded)
{
if (Input.GetButtonDown("Jump"))
{
rb.AddForce(Vector3.up * jumpHeight);
NumberJumps += 1;
}
}
}
void OnCollisionEnter(Collision other)
{
isGrounded = true;
NumberJumps = 0;
}
void OnCollisionExit(Collision other)
{
}
}
Also in C#:
- Title
- c# create new thread
- Category
- C#
- Title
- unity deactive code from code
- Category
- C#
- Title
- c# store generic type without arguments
- Category
- C#
- Title
- transform.Translate movement
- Category
- C#
- Title
- what data type should be for contact number in asp.net
- Category
- C#
- Title
- query associative table ef6
- Category
- C#
- Title
- c# filesystemwatcher double events
- Category
- C#
- Title
- c# tab character
- Category
- C#
- Title
- eager loading vs lazy loading c#
- Category
- C#
- Title
- c# stop loop
- Category
- C#
- Title
- return random from enum
- Category
- C#
- Title
- c# skip following code in loop
- Category
- C#
- Title
- transform object according to its parent unity
- Category
- C#
- Title
- c# loop datatable rows
- Category
- C#
- Title
- how to use variables in c#
- Category
- C#
- Title
- c# make string null
- Category
- C#
- Title
- unity how to add a bullet impact force
- Category
- C#
- Title
- c sharp string replace
- Category
- C#
- Title
- set label position winforms
- Category
- C#
- Title
- onmouseclick unity
- Category
- C#
- Title
- Could not load file or assembly 'Ubiety.Dns.Core, Version=2.2.1.0
- Category
- C#
- Title
- check if current time is in the morning c#
- Category
- C#
- Title
- c# move with arrow keys
- Category
- C#
- Title
- how to mock abstract httpcontext using moq .net core
- Category
- C#
- Title
- unity coroutine
- Category
- C#
- Title
- unity prevent system from creation
- Category
- C#
- Title
- c# convert dictionary to anonymous object
- Category
- C#
- Title
- bulk update in c# using jquery datatble
- Category
- C#
- Title
- response redirect new tab
- Category
- C#
- Title
- unity vector3 to array
- Category
- C#
- Title
- asp.net core redirecttoaction with parameters
- Category
- C#
- Title
- unity get child
- Category
- C#
- Title
- c# tuple access
- Category
- C#
- Title
- c# convert utc to est
- Category
- C#
- Title
- no overload for 'useItemOnSceneLoad' matches delegate 'UnityAction<Scene, LoadSceneMode>'
- Category
- C#
- Title
- install .net sdk ubuntu 20
- Category
- C#
- Title
- reference to gameobject in different scene unity
- Category
- C#
- Title
- c# datafield change cell background color
- Category
- C#
- Title
- isdaylightsavingtime in c#
- Category
- C#
- Title
- unity c# set gameobject active
- Category
- C#
- Title
- as c#
- Category
- C#
- Title
- split string
- Category
- C#
- Title
- get user directory of file in c#
- Category
- C#
- Title
- how to switch scenes unity
- Category
- C#
- Title
- how get data from json in c#
- Category
- C#
- Title
- c# loop string array
- Category
- C#
- Title
- unity how to get data of play session time in a text file?
- Category
- C#
- Title
- c sharp comments
- Category
- C#
- Title
- C# events
- Category
- C#
- Title
- player script unity
- Category
- C#
- Title
- c# get time
- Category
- C#
- Title
- how to run csharp in visual studio code
- Category
- C#
- Title
- windows form rounded corners
- Category
- C#
- Title
- c# System.Resources.MissingManifestResourceException error
- Category
- C#
- Title
- xamarin forms alarm
- Category
- C#
- Title
- asp net mvc 5 return view from another controller
- Category
- C#
- Title
- c# empty char
- Category
- C#
- Title
- unity fps counter
- Category
- C#
- Title
- c# convert Unix time in seconds to datetime
- Category
- C#
- Title
- c# change colour of console
- Category
- C#
- Title
- httpcontext in .net standard
- Category
- C#
- Title
- : ? conditioanl statement c#
- Category
- C#
- Title
- HashSet C# append
- Category
- C#
- Title
- how to initiate a varaible in cs
- Category
- C#
- Title
- how to textbox anywhere on chart in c#
- Category
- C#
- Title
- nunit return parameter
- Category
- C#
- Title
- if and c#
- Category
- C#
- Title
- c# get foreground window
- Category
- C#
- Title
- convert array to list Unity C#
- Category
- C#
- Title
- c# string formatting
- Category
- C#
- Title
- c# resize bitmap
- Category
- C#
- Title
- null coalescing operator c#
- Category
- C#
- Title
- Instantiate c#
- Category
- C#
- Title
- c# get pc ip address
- Category
- C#
- Title
- external font family uwp c#
- Category
- C#
- Title
- drag object unity 2d
- Category
- C#
- Title
- how to turn a string in a char list c#
- Category
- C#
- Title
- entity framework core
- Category
- C#
- Title
- c# delay
- Category
- C#
- Title
- c# find element by condition
- Category
- C#
- Title
- getcomponent c#
- Category
- C#
- Title
- unity 3d mouse look script
- Category
- C#
- Title
- verifyusertokenasync password reset token
- Category
- C#
- Title
- unity c# get bool from another script
- Category
- C#
- Title
- how to reference a transform unity
- Category
- C#
- Title
- how to make pressing enter an event in c#
- Category
- C#
- Title
- random from list c#
- Category
- C#
- Title
- remove from list based on condition c#
- Category
- C#
- Title
- unity collider2d contains point
- Category
- C#
- Title
- eventos c#
- Category
- C#
- Title
- how to add to an array c#
- Category
- C#
- Title
- make camera follow character unity 2020
- Category
- C#
- Title
- c# get desktop path
- Category
- C#
- Title
- asp.net get query string parameter
- Category
- C#
- Title
- in unity i want to destroy a gameobject when it hits the edge of the screen
- Category
- C#
- Title
- how to make a pause feautre in unity
- Category
- C#
- Title
- edit form item from class C#
- Category
- C#
- Title
- c# stop loop in method
- Category
- C#
- Title
- C# get all child classes of a class
- Category
- C#
- Title
- how to add a gameobject
- Category
- C#