燮transform.translate太快。当我按下C按钮时,我的精灵速度过快。这是一只狼,将作为攻击刺探。但它只是从一个地方到另一个地方,而我的想法是我完全使用了错误的代码。我猜它必须用Rigidbody2D = new Vector2
做更多......但我不知道从那里去哪里。以下是我目前正在处理的内容。2D精灵去与C#脚本(单位)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class tulMoveMount : MonoBehaviour {
private Animator anim;
private Rigidbody2D rb;
private bool goRight = true;
private bool jump = false;
private bool idle = true;
public float lungeDistance;
public float lungeSpeed;
public float lungeHeight;
void Start()
{
anim = GetComponent<Animator>();
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
HandleCommands();
}
void HandleCommands()
{
if (!jump && goRight && Input.GetKeyDown (KeyCode.C)) {
idle = false;
jump = true;
anim.SetTrigger ("jump");
rb = transform.Translate (lungeSpeed + lungeDistance, lungeHeight, 0); // HERE
idle = true;
jump = false;
anim.SetTrigger ("idle");
}
if (!jump && !goRight && Input.GetKeyDown (KeyCode.C)) {
idle = false;
jump = true;
anim.SetTrigger ("jump");
rb = transform.Translate (lungeSpeed + -lungeDistance, lungeHeight, 0); // HERE
idle = true;
jump = false;
anim.SetTrigger ("idle");
}
}
}
好的。你基本上只是给了我整个代码并解决了问题。我不知道你是从哪里来的超级英雄,但是感谢大声笑 –
@JoeClark哈哈。不用谢。我试图解决你以及你翻转2D Sprite的问题,但不确定接近的工作 –