Beispiel #1
0
        private WalkSakura sakura;//点击反馈

        void Awake()
        {
            if (Instance != this)
            {
                Destroy(gameObject);
                return;
            }

            //设置人物脚步声
            m_audioSource        = GetComponent <AudioSource>();
            m_audioSource.clip   = walkingMusic;
            m_audioSource.volume = AudioController.Instance.soundEffectVolume;

            forwardable                  = true;
            m_renderer                   = GetComponent <SpriteRenderer>();
            m_animator                   = GetComponent <Animator>();
            IsWalking                    = Animator.StringToHash("isWalking");
            m_capsule                    = GetComponent <CapsuleCollider2D>();
            m_rigidbody2D                = GetComponent <Rigidbody2D>();
            m_contactFilter.layerMask    = groundedLayerMask;
            m_contactFilter.useLayerMask = true;
            m_contactFilter.useTriggers  = true;
            sakura = GameObject.Find("OnClickSakura").GetComponent <WalkSakura>();

            m_destPos      = m_rigidbody2D.position;
            touchThreshold = m_capsule.bounds.max.y - m_capsule.bounds.min.y + 0.8f;
            //Debug.Log("touchThreold" + touchThreshold);

            //因为人的包围盒的中心与Transform的中心不一样
            UpdateCenterHeight();
        }