Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

jump in unity

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(Rigidbody))]
public class PlayerController : MonoBehaviour {
    public Vector3 jump;
    public float jumpForce = 2.0f;

    public bool isGrounded;
    Rigidbody rb;
    void Start(){
        rb = GetComponent<Rigidbody>();
        jump = new Vector3(0.0f, 2.0f, 0.0f);
    }

    void OnCollisionStay(){
        isGrounded = true;
    }

    void Update(){
        if(Input.GetKeyDown(KeyCode.Space) && isGrounded){

            rb.AddForce(jump * jumpForce, ForceMode.Impulse);
            isGrounded = false;
        }
    }
}
Comment

How to jump in Unity using physics 3D

Rigidbody.AddForce(Vector3 force);Copy
Comment

How to jump in Unity using physics

Rigidbody.AddForce(Vector3 force);Copied!
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity save scene at runtime 
Csharp :: c# textbox kodu 
Csharp :: c# generate random string 
Csharp :: except method c# 
Csharp :: how to return array in function c# 
Csharp :: convert json date to datetime c# 
Csharp :: hashtable in c# 
Csharp :: C# [] overload 
Csharp :: c# interface property 
Csharp :: generic interface c# 
Csharp :: convert xml to json 
Csharp :: Transpose Matrix C Sharp 
Csharp :: user input to array object c# 
Csharp :: how to filter a list in c# 
Csharp :: c# out argument 
Csharp :: how to add object in dictionary in c# 
Csharp :: jtoken toobject is not exact double 
Csharp :: why does everything reset when switching scene unity 
Csharp :: system.componentmodel.dataannotations hide field 
Csharp :: internal working of ioc container c# 
Csharp :: c++ printwindow chrome 
Csharp :: asp.net core 6 get current culture in controller 
Csharp :: how to refresh the data table in C# window form datagridview 
Csharp :: photon 
Csharp :: Toggle value change 
Csharp :: c# insert from with bind array 
Csharp :: c# logical operators 
Csharp :: principalcontext c# example 
Csharp :: how to make build events always run visual studio 
Csharp :: sequelize instance method is not a function 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =