燮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的問題,但不確定接近的工作 –