小编use*_*504的帖子

Unity 2d跳跃脚本

有没有人在团结的2D游戏中有一个好的跳跃剧本?我的代码有效,但仍然远没有跳跃,看起来它正在飞行.

using UnityEngine;
using System.Collections;

public class movingplayer : MonoBehaviour {

public Vector2 speed = new Vector2(10,10);

private Vector2 movement = new Vector2(1,1);

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
    float inputX = Input.GetAxis ("Horizontal");
    float inputY = Input.GetAxis ("Vertical");

    movement = new Vector2(
        speed.x * inputX,
        speed.y * inputY);

    if (Input.GetKeyDown ("space")){
                         transform.Translate(Vector3.up * 260 * Time.deltaTime, Space.World);
                 } 

}
void FixedUpdate()
{
    // 5 …
Run Code Online (Sandbox Code Playgroud)

c# physics unity-game-engine

11
推荐指数
2
解决办法
8万
查看次数

标签 统计

c# ×1

physics ×1

unity-game-engine ×1