目前,我的脚本是将玩家移动到场景周围.我怎样才能顺利移动?
void FixedUpdate()
{
bool running = Input.GetKey(KeyCode.LeftShift);
float h = Input.GetAxisRaw("Horizontal");
float v = Input.GetAxisRaw("Vertical");
bool isWalking = Mathf.Abs(h) + Mathf.Abs(v) > 0;
movement = ((running) ? runSpeed : walkSpeed) * new Vector3(h, 0.0f, v).normalized;
if (isWalking)
{
transform.position += movement * Time.fixedDeltaTime;
transform.LookAt(transform.position + movement);
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个简单的代码,当玩家输入一个触发器时显示一个精灵:
ps:精灵不在GUI上
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player")
{
ItemCard.SetActive(true);
}
else
{
ItemCard.SetActive(false);
}
}
Run Code Online (Sandbox Code Playgroud)
但是我SetActive(false)没有工作,精灵仍在展示.我在伪造什么?