这是一个简单的双跳脚本,但我也想让它回应触摸
private LlatformerCharacter2D character;
private bool jump;
void Awake () {
character = GetComponent<LlatformerCharacter2D>();
}
void Update () {
if (Input.GetButtonDown("Jump"))
jump = true;
}
void FixedUpdate() {
character.Move (1, false, jump);
jump = false;
}
答案 0 :(得分:0)
用对撞机制作一个物体并将其标记为跳跃(这将是你的跳跃按钮)并检查它是否被触摸
void Update () {
if (Input.GetMouseButtonDown (0)) {
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit)) {
if(hit.collider.tag=="Jump")
jump = true;
}
}
}