本文整理汇总了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;
}
示例2: Awake
void Awake() {
instance = this;
characterController = GetComponent<CharacterController>() as CharacterController;
this._currentBlock = null;
this._currentDirection = PlayerInfo.MovementDirection.NONE;
}
示例3: Start
void Start()
{
_characterController = GetComponent<CharacterController>();
StartCoroutine(RandomInputJump());
StartCoroutine(RandomInputSpeed());
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
}
示例7: Awake
void Awake()
{
playerController = GetComponent<CharacterController>();
entityBehaviour = GetComponent<DaggerfallEntityBehaviour>();
entityBehaviour.OnSetEntity += EntityBehaviour_OnSetEntity;
mainCamera = GameManager.Instance.MainCamera;
}
示例8: Awake
void Awake()
{
controller = GetComponent<CharacterController>();
smoothCamera = GetComponentInChildren<SmoothCameraWithBumper>();
audioSource = GetComponentInChildren<AudioSource>();
anim = GetComponent<Animation>();
}
示例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);
}
示例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> ();
}
示例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>();
}
示例12: Start
void Start()
{
anim = GetComponent<Animator>();
cont = GetComponent<CharacterController>();
currentMovement = GetComponent<AIPath>();
isShiftDown = false;
slowMoTime = 0f;
}
示例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;
}
示例14: Start
/** Use this for initialization */
public void Start () {
seeker = GetComponent<Seeker>();
controller = GetComponent<CharacterController>();
navmeshController = GetComponent<NavmeshController>();
tr = transform;
Repath ();
}
示例15: OnEnter
public override void OnEnter ()
{
charCtrl = startingObj.Value.GetComponent<CharacterController>();
DoSphereCast ();
if (!everyFrame) {
Finish();
}
}