【发布时间】:2018-08-24 02:26:11
【问题描述】:
我在 Unity C# 上编写游戏
这是简单的跑步者。
我有 Platformer2DUserControl 脚本。
这里是
using UnityEngine;
using UnitySampleAssets.CrossPlatformInput;
namespace UnitySampleAssets._2D
{
[RequireComponent(typeof (PlatformerCharacter2D))]
public class Platformer2DUserControl : MonoBehaviour
{
private PlatformerCharacter2D character;
private bool jump ;
private void Awake()
{
character = GetComponent<PlatformerCharacter2D>();
}
private void Update()
{
if (Input.touchCount > 0)
character.Move(1, false, jump);
if (!jump)
// Read the jump input in Update so button presses aren't missed.
jump = CrossPlatformInputManager.GetButtonDown("Jump");
}
private void FixedUpdate()
{
// Read the inputs.
bool crouch = Input.GetKey(KeyCode.LeftControl);
// float h = CrossPlatformInputManager.GetAxis("Horizontal");
// Pass all parameters to the character control script.
character.Move(1, false, jump);
jump = false;
}
}
}
当我在手机上触摸屏幕时,我试图让那个播放器跳跃。
但它不会跳。
我的代码有什么问题?
感谢您的帮助。
【问题讨论】: