Answer the question
In order to leave comments, you need to log in
How to do one jump in unity?
I made a script for the main character, but if you press the spacebar all the time, then he flies out of the map, how to make a single jump? Here is the script.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class perss : MonoBehavior {
Rigidbody2D rb;
void Start() {
rb = GetComponent();
}
void Update () {
if (Input.GetKeyDown (KeyCode.Space)) {
pipirka ();
}
}
void FixedUpdate () {
rb.velocity = new Vector2(Input.GetAxis("Horizontal") * 9f, rb.velocity.y);
}
void pipirka(){
rb.AddForce(transform.up * 7f, ForceMode2D.Impulse);
}
void Reload(){
Application.LoadLevel(Application.loadedLevel);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question