Unity - A计划(永久有效期) 扫二维码继续学习 二维码时效为半小时

(196评价)
价格: 4019.00元
Stealth秘密行动遇到问题了
keepworking发起了问答2017-06-26
5
回复
2884
浏览

学习Stealth秘密行动遇到问题

 

老师你在这个课程是可以直接用

private void PlaySiren()
    {
        foreach(GameObject go in sirens)
        {
            if(!go.audio.isPlaying)
        }
    }直接访问audio组件,而我不能访问呢。而我这边就没有go.aduio.isplaying这个方法vs里面提示是这么办呀

所有回复
  • sdhexu 2017-06-26

    提示已经很清楚了。使用GetComponent<AudioSource>()获取组件先。

    • keepworking 2017-06-26

      提示是写Gameobject.audio已经过时是什么 意思,然后我用 GetComponent<AudioSouser>();获取了组件 但是还是提示这个错误

      (0) 回复
    还有-4条回复,点击查看
    你还没有登录,请先登录注册
  • siki 2017-06-26

    这个组件以前是内置组件,可以直接获取,现在要通过代码获取,是哪个游戏物体的就调用哪个游戏物体身上的GetComponent组件

    go.GetComponent<AudioSouser>().isPlaying

    还有-5条回复,点击查看
    你还没有登录,请先登录注册
  • lyqdon 2018-01-19

    老师,stealth用UNITY 5.6 控制玩家跑动的代码,是否在这版本中无法使用?我看了好几遍代码跟视频一样的

     public float moveSpeed = 30;
        public float stopSpeed = 20;
        public float rotateSpeed = 1;
        private Animator anim;

        void Awake()
        {
            anim = this.GetComponent<Animator>();
        }

        void Update()
        {
            float h = Input.GetAxis("Horizontal");
            float v = Input.GetAxis("Vertical");

            if(Mathf.Abs(h)>0.1|| Mathf.Abs(v) > 0.1)
            {
                float newSpeed = Mathf.Lerp(anim.GetFloat("Speed"), 5.6f, moveSpeed * Time.deltaTime);
                anim.SetFloat("Speed",newSpeed);

                Vector3 targetDir = new Vector3(h, 0, 0);
                Vector3 nowDir = transform.forward;
                float angle=  Vector3.Angle(nowDir, targetDir);
                
                if (angle > 180)
                {
                    angle = 360 - angle;
                    angle = -angle;
                }
                transform.Rotate(Vector3.up*angle*Time.deltaTime* rotateSpeed);
            }
            else
            {
                //float newSpeed = Mathf.Lerp(anim.GetFloat("Speed"), 0f, stopSpeed * Time.deltaTime);
                anim.SetFloat("Speed", 0);
            }
        }

    • siki 2018-01-25

      这个可以使用unity4.6来开发哦
      问题应该是在运动过程中应该 navmeshAgent.NextPosition=transform.position;

      (0) 回复
    还有-4条回复,点击查看
    你还没有登录,请先登录注册
发表回复
你还没有登录,请先 登录或 注册!