小编The*_*t22的帖子

如何检查动画师的某个动画状态是否正在运行?

我创建了一个名为“m4a4animator”的动画师。在其中,主要功能称为“空闲”(无),其他 2 种状态:“射击”(mouse0)和“重新加载”(R)。这 2 个动画状态转换为“空闲”。现在,一切正常......但我唯一的问题是:如果我正在重新加载并按下鼠标0(射击),动画运行状态立即更改为射击......但我想阻止它.

现在,问题是:如何在动画运行时停止某些动画更改?

这是我的动画师

这是我的脚本:

using UnityEngine;
using System.Collections;

public class m4a4 : MonoBehaviour {

    public Animator m4a4animator;

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {
        if (Input.GetKeyDown (KeyCode.R)) {

            m4a4animator.Play("reload");

        }

        if (Input.GetMouseButton(0)) {

            m4a4animator.Play("shoot");

        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# animation unity-game-engine animator

3
推荐指数
1
解决办法
1万
查看次数

"意外的符号`else'"如何修复此问题(if语句后没有分号)?

我在第56行收到错误...有人可以告诉我为什么吗?我没有在if语句的末尾添加任何分号,我也使用右括号放置......这里有什么问题?我将不胜感激,谢谢!

这是我的代码:

using UnityEngine;
using System.Collections;

public class PlayerPrefsManager : MonoBehaviour {

    const string MASTER_VOLUME_KEY = "master_volume";
    const string DIFFICULTY_KEY = "difficulty";
    const string LEVEL_KEY = "level_unlocked_";

    public static void SetMasterVolume(float volume)
    {
        if (volume > 0f && volume < 1f) {

            PlayerPrefs.SetFloat (MASTER_VOLUME_KEY, volume);

        } else {

            Debug.LogError ("Master volume out of range");

        }
    }

    public static float GetMasterVolume()
    {
        return PlayerPrefs.GetFloat (MASTER_VOLUME_KEY);
    }

    public static void UnlockLevel (int level)
    {
        if (level <= Application.levelCount - 1) {

            PlayerPrefs.SetInt(LEVEL_KEY …
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine

-8
推荐指数
1
解决办法
205
查看次数

标签 统计

c# ×2

unity-game-engine ×2

animation ×1

animator ×1