Unity3D学习记录——刚体跳跃

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Jump : MonoBehaviour {

    private Rigidbody m_rigidbody;

	// Use this for initialization
	void Start () {
        m_rigidbody = gameObject.GetComponent();
	}
	
	// Update is called once per frame
	void Update () {
        if (Input.GetKey(KeyCode.Space)) {
            m_rigidbody.velocity = new Vector3(0, 4.1f, 0);
        }
	}
}

你可能感兴趣的:(Unity3D)