当前位置: 首页>>代码示例>>C#>>正文


C# UnityEngine.CharacterController类代码示例

本文整理汇总了C#中UnityEngine.CharacterController的典型用法代码示例。如果您正苦于以下问题:C# CharacterController类的具体用法?C# CharacterController怎么用?C# CharacterController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CharacterController类属于UnityEngine命名空间,在下文中一共展示了CharacterController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

 void Start()
 {
     anim = GetComponent<Animator>();
     controller = GetComponent<CharacterController>();
     oldPosX = transform.position.x;
     oldPosZ = transform.position.z;
 }
开发者ID:tyjfox,项目名称:Craig,代码行数:7,代码来源:AvatarMovement.cs

示例2: Awake

        void Awake() {
            instance = this;
            characterController = GetComponent<CharacterController>() as CharacterController;

            this._currentBlock = null;
            this._currentDirection = PlayerInfo.MovementDirection.NONE;
        }
开发者ID:ChrisJong,项目名称:Harmony,代码行数:7,代码来源:AIController.cs

示例3: Start

        void Start()
        {
            _characterController = GetComponent<CharacterController>();

            StartCoroutine(RandomInputJump());
            StartCoroutine(RandomInputSpeed());
        }
开发者ID:millwardesque,项目名称:TrainDevChallenge,代码行数:7,代码来源:PlayerInputBot.cs

示例4: Start

        // Use this for initialization
        private void Start()
        {
            if (PlayerPrefs.GetInt("Nb change", 0) == 1)
                Destroy(change1);
            else if (PlayerPrefs.GetInt("Nb change", 0) == 2)
            {
                Destroy(change1);
                Destroy(change2);
            }
            DestroyChange();
            Volume.value = 1;
            m_CharacterController = GetComponent<CharacterController>();
            m_Camera = Camera.main;
            m_OriginalCameraPosition = m_Camera.transform.localPosition;
            m_FovKick.Setup(m_Camera);
            m_HeadBob.Setup(m_Camera, m_StepInterval);
            m_StepCycle = 0f;
            m_NextStep = m_StepCycle/2f;
            m_Jumping = false;
            m_AudioSource = GetComponent<AudioSource>();
			m_MouseLook.Init(transform , m_Camera.transform);
            Listener = GetComponentInChildren<AudioListener>();
            if (Application.loadedLevel == 1)
                m_CharacterController.transform.position = new Vector3(PlayerPrefs.GetFloat("Xpos", 21.9f), PlayerPrefs.GetFloat("Ypos",1),PlayerPrefs.GetFloat("Zpos", -23.32f));
            m_CharacterController.transform.rotation= new Quaternion(PlayerPrefs.GetFloat("Xrot", 0), PlayerPrefs.GetFloat("Yrot", 0), PlayerPrefs.GetFloat("Zrot", 0),0);
        }
开发者ID:DarkCookies,项目名称:The-Life-Breaker,代码行数:27,代码来源:FirstPersonController.cs

示例5: OnUpdate

        private GameObject previousGo; // remember so we can get new controller only when it changes.

        #endregion Fields

        #region Methods

        public override void OnUpdate()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);
            if (go == null) return;

            if (go != previousGo)
            {
                controller = go.GetComponent<CharacterController>();
                previousGo = go;
            }

            if (controller != null)
            {
                var move = space == Space.World ? moveVector.Value : go.transform.TransformDirection(moveVector.Value);

                if (perSecond.Value)
                {
                    controller.Move(move * Time.deltaTime);
                }
                else
                {
                    controller.Move(move);
                }
            }
        }
开发者ID:Streek,项目名称:FSM-Action-Collection-for-UN-PM,代码行数:31,代码来源:ControllerMove.cs

示例6: OnUpdate

 public override void OnUpdate()
 {
     GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.gameObject);
     if (ownerDefaultTarget == null)
     {
         return;
     }
     if (ownerDefaultTarget != this.previousGo)
     {
         this.controller = ownerDefaultTarget.GetComponent<CharacterController>();
         this.previousGo = ownerDefaultTarget;
     }
     if (this.controller != null)
     {
         Vector3 vector = (this.space != Space.World) ? ownerDefaultTarget.transform.TransformDirection(this.moveVector.Value) : this.moveVector.Value;
         if (this.perSecond.Value)
         {
             this.controller.Move(vector * Time.deltaTime);
         }
         else
         {
             this.controller.Move(vector);
         }
     }
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:25,代码来源:ControllerMove.cs

示例7: Awake

 void Awake()
 {
     playerController = GetComponent<CharacterController>();
     entityBehaviour = GetComponent<DaggerfallEntityBehaviour>();
     entityBehaviour.OnSetEntity += EntityBehaviour_OnSetEntity;
     mainCamera = GameManager.Instance.MainCamera;
 }
开发者ID:my0pic,项目名称:daggerfall-unity,代码行数:7,代码来源:PlayerDeath.cs

示例8: Awake

 void Awake()
 {
     controller = GetComponent<CharacterController>();
     smoothCamera = GetComponentInChildren<SmoothCameraWithBumper>();
     audioSource = GetComponentInChildren<AudioSource>();
     anim = GetComponent<Animation>();
 }
开发者ID:WhiteRavensGame,项目名称:JRPGTownPrototype,代码行数:7,代码来源:SimpleController.cs

示例9: Start

        // Use this for initialization
        private void Start()
        {
        	if (Application.loadedLevelName == "Sanctuary")
        	{
        		Sprint = true;
        		m_WalkSpeed = 5;
        		m_RunSpeed = 10;
        	}
        	else
        	{
				m_WalkSpeed = GetComponent<combatStats>().walkSpeed;
				m_RunSpeed = GetComponent<combatStats>().runSpeed;
				m_CrouchSpeed = GetComponent<combatStats>().crouchSpeed;
        	}
            m_CharacterController = GetComponent<CharacterController>();
            m_Camera = Camera.main;
            m_OriginalCameraPosition = m_Camera.transform.localPosition;
            m_FovKick.Setup(m_Camera);
            m_HeadBob.Setup(m_Camera, m_StepInterval);
            m_StepCycle = 0f;
            m_NextStep = m_StepCycle/2f;
            m_Jumping = false;
            m_AudioSource = GetComponent<AudioSource>();
			m_MouseLook.Init(transform , m_Camera.transform);
        }
开发者ID:hydrater,项目名称:TLH,代码行数:26,代码来源:FirstPersonController.cs

示例10: Awake

        float camRayLength = 100f;          // The length of the ray from the camera into the scene.

        void Awake ()
        {

            // Set up references.
            anim = GetComponent <Animator> ();
			character = GetComponent<CharacterController>();
            //playerRigidbody = GetComponent <Rigidbody> ();
        }
开发者ID:coderespawn,项目名称:dungeon-architect-quick-start-unity,代码行数:10,代码来源:PlayerMovement.cs

示例11: Awake

        Vector3 movement; // The vector to store the direction of the player's movement.

        #endregion Fields

        #region Methods

        void Awake()
        {
            // Create a layer mask for the floor layer.
            floorMask = LayerMask.GetMask ("Floor");

            // Set up references.
            controller = this.GetComponent<CharacterController>();
        }
开发者ID:micik,项目名称:OdessaInnovationWeek2015UnityWorkshop,代码行数:14,代码来源:PlayerMovement.cs

示例12: Start

 void Start()
 {
     anim = GetComponent<Animator>();
     cont = GetComponent<CharacterController>();
     currentMovement = GetComponent<AIPath>();
     isShiftDown = false;
     slowMoTime = 0f;
 }
开发者ID:DontWorry33,项目名称:TheNeutral,代码行数:8,代码来源:MinorAStarController.cs

示例13: Start

		public void Start () {
			guns = GetComponentsInChildren<GunShooting>();
			seeker = GetComponent<Seeker>();
			controller = GetComponent<CharacterController>();
			animator = GetComponentInChildren<Animator>();
			if (target != null)
				target.transform.position = transform.position;
		}
开发者ID:pateldhruv1993,项目名称:Basic-RTS-Mechanics-Unity3D,代码行数:8,代码来源:FollowPathfinder.cs

示例14: Start

        /** Use this for initialization */
        public void Start () {
            seeker = GetComponent<Seeker>();
            controller = GetComponent<CharacterController>();
            navmeshController = GetComponent<NavmeshController>();
		
            tr = transform;
            Repath ();
        }
开发者ID:luukholleman,项目名称:Airchitect,代码行数:9,代码来源:AIFollow.cs

示例15: OnEnter

		public override void OnEnter ()
		{
			charCtrl = startingObj.Value.GetComponent<CharacterController>();
			DoSphereCast ();
			if (!everyFrame) {
				Finish();			
			}
		}
开发者ID:tchrisbaker,项目名称:Unity3DRPG,代码行数:8,代码来源:MyRayCast.cs


注:本文中的UnityEngine.CharacterController类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。