using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class jump : MonoBehaviour {
public float jumpvalue;
private Rigidbody2D rd;
private void Awake()
{
rd = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update () {
if(Input.GetKeyDown(KeyCode.Space))
{
rd.velocity = Vector2.up * jumpvalue;
}
}
}
更好的跳跃
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class jump : MonoBehaviour {
public float fallMultiplier = 2.5f;
public float lowMultiplier = 2f;
public float jumpvalue;
private Rigidbody2D rd;
private void Awake()
{
rd = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update () {
if(Input.GetKeyDown(KeyCode.Space))
{