小编d d*_*doe的帖子

平滑的Lerp运动?

目前,我的脚本是将玩家移动到场景周围.我怎样才能顺利移动?

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)

c# unity-game-engine

7
推荐指数
1
解决办法
830
查看次数

如何使用SetActive禁用精灵(false)

我有一个简单的代码,当玩家输入一个触发器时显示一个精灵:

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)没有工作,精灵仍在展示.我在伪造什么?

c# unity-game-engine

0
推荐指数
1
解决办法
122
查看次数

标签 统计

c# ×2

unity-game-engine ×2