【发布时间】:2021-04-27 11:53:23
【问题描述】:
我正在观看一段关于如何制作 2D 动画的旧 brackeys 视频,我相信我已经正确地遵循了教程中的所有内容。一切都很顺利,直到我开始跳跃动画。在着陆功能期间跳跃动画不会停止。视频在这里https://www.youtube.com/watch?v=hkaysu1Z-N8&feature=emb_logo,我的代码是这样的:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public CharacterController2D controller;
public float runSpeed = 80f;
float horiztalMove = 0f;
bool jump = false;
public Animator animator;
// Start is called before the first frame update
// Update is called once per frame
void Update()
{
horiztalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
animator.SetFloat("Speed", Mathf.Abs(horiztalMove));
if (Input.GetButtonDown("Jump"))
jump = true;
animator.SetBool("Jumping", true);
}
public void OnLanding ()
{
animator.SetBool("Jumping", false);
}
void FixedUpdate()
{ //move our character
controller.Move(horiztalMove * Time.fixedDeltaTime, false, jump);
jump = false;
}
} 如果您希望我发送任何其他代码或屏幕截图,我会发送。
【问题讨论】: