void Update() { Fsm?.Update(); Movement?.Update(); Rotation?.Update(); Scale?.Update(); }
/// <summary> /// Update the position of the camera. /// </summary> /// <param name="position">The new position for the camera.</param> /// <param name="postionDelta">The delta to be applied to the position for interpolation.</param> /// <param name="orientation">The look at vector for the camera orientation.</param> /// <param name="orientationDelta">The delta to be applied to the look at vector for interpolation.</param> /// <param name="mode">How the camera is to be updated. Can override the current global ControlMode setting.</param> public void Update(Vector3 position, Vector3 postionDelta, Rotation orientation, Rotation orientationDelta, ControlMode mode) { if (mEnableUpdates) { #if DEBUG mUpdateStats.Begin(); #endif mPositionDelta = postionDelta; mOrientationDelta.Update(mRotationLock, orientationDelta); if (mode == Chimera.ControlMode.Absolute) { int x = (int)position.X; int y = (int)position.Y; float height = x >= 0 && x < mHeightmap.GetLength(0) && y >= 0 && y < mHeightmap.GetLength(1) ? mHeightmap[x, y] : mDefaultHeight; height += .5f; if (position.Z < height) { position.Z = height; postionDelta.Z = 0f; } mPosition = position; mOrientation.Update(mRotationLock, orientation); if (CameraUpdated != null && mAlive) { CameraUpdateEventArgs args = new CameraUpdateEventArgs(position, postionDelta, orientation, orientationDelta); #if DEBUG mCameraStats.Begin(); #endif CameraUpdated(this, args); #if DEBUG mCameraStats.End(); #endif //Console.WriteLine("TickFrequency - time since update: " + (mTickLength - DateTime.Now.Subtract(mLastUpdate).TotalMilliseconds)); mLastUpdate = DateTime.UtcNow; } } else if (DeltaUpdated != null && mAlive) { DeltaUpdateEventArgs args = new DeltaUpdateEventArgs(postionDelta, orientationDelta); #if DEBUG mDeltaStats.Begin(); #endif DeltaUpdated(this, args); #if DEBUG mDeltaStats.End(); #endif } #if DEBUG mUpdateStats.End(); #endif } }
// Update is called once per frame void Update() { InputDir = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")); rotation.Update(InputDir); isHit = GetHit(beforePosition, transform.position, transform.forward, 0.5f); if (isHit) { } else { if (InputDir.magnitude != 0) { beforePosition = transform.position; this.transform.position += transform.forward * moveSpeed * Time.fixedDeltaTime; } } }
public void Update() { Movement?.Update(); Rotation?.Update(); Scale?.Update(); }
void LateUpdate() { // Cache the rendered of the target if (target != m_cachedTarget) { m_targetRenderer = target != null?target.GetComponent <Renderer>() : null; m_cachedTarget = target; } // Update each rotation float dt = Time.deltaTime; Transform reference = rotateInWorldSpace? null : m_trans.parent; horizontal.Update(dt, m_trans, target, m_targetRenderer, reference); vertical.Update(dt, m_trans, target, m_targetRenderer, reference); pitch.Update(dt, m_trans, target, m_targetRenderer, reference); // Calculate and apply the rotation Quaternion rot = new Quaternion(); if (invertHVorder) { rot = vertical.rotation * horizontal.rotation; } else { rot = horizontal.rotation * vertical.rotation; } rot = rot * pitch.rotation; if (rotateInWorldSpace) { m_trans.rotation = rot; } else { m_trans.localRotation = rot; } // Trigger the onRotationFinished delegate if (vertical.isRotating || horizontal.isRotating || pitch.isRotating) { m_rotating = true; } else { if (m_rotating) { m_rotating = false; if (onRotationFinished != null) { onRotationFinished(); } } } }
void Action() { switch (player_status) { case Status.idle: isInvincible = false; rotation.Update(Input_dir); move.Update(Input_dir, isGrounded, isHit_against_theWall); gravity.Update(isGrounded); break; case Status.jumpping: gravity.Update(true); jump.Jumpping(this.transform); move.Update(Input_dir, false, isHit_against_theWall); rotation.Update(Input_dir); if (jump.isjumpping == false) { GetStatus(Status.idle); } break; case Status.guarding: damage.UPFukitobi(isHit_against_theWall); damage.SIDEFukitobi(isHit_against_theWall); if (guard.transitionProperty == Guard.Transition.Guarding) { if (Input_dir.magnitude != 0) { guard.gobj.SetActive(false); step.Start(Input_dir, true); GetStatus(Status.stepping); break; } } guard.Guarding(); gravity.Update(isGrounded); if (guard.isGuarding == false) { GetStatus(Status.idle); } break; case Status.attacking: attack.Attacking(); attack.isGrounded = isGrounded; if (attack.isAttacking == false) { GetStatus(Status.idle); } if (!isGrounded) { move.Update(Input_dir, false, isHit_against_theWall); } break; case Status.stepping: step.Stepping(isHit_against_theWall); isInvincible = step.invincibleProperty > 0 ? true : false; if (!step.isStepping) { GetStatus(Status.idle); } break; case Status.damaged: guard.gobj.SetActive(false); if (damage.Wait()) { if (!isGrounded && Input.anyKeyDown) //受身 { transform.localEulerAngles = new Vector3 (transform.localEulerAngles.x, transform.localEulerAngles.y, 0); wait.Set(30, 0); GetStatus(Status.waiting); } if (isGrounded && damage.UPFukitobi(isHit_against_theWall) && damage.SIDEFukitobi(isHit_against_theWall)) { wait.Set(40, 0); wait.Waiting(); if (wait.Waiting() == true) { transform.localEulerAngles = new Vector3 (transform.localEulerAngles.x, transform.localEulerAngles.y, 0); GetStatus(Status.idle); } } } else { wait.Set(3, 0); wait.Waiting(); if (wait.Waiting() == true) { isInvincible = false; } else { isInvincible = true; } } damage.UPFukitobi(isHit_against_theWall); if (damage.UPFukitobi(isHit_against_theWall)) { gravity.Update(isGrounded); } damage.SIDEFukitobi(isHit_against_theWall); break; case Status.waiting: wait.Waiting(); if (wait.Waiting() == true) { GetStatus(Status.idle); } break; case Status.Down: this.gameObject.SetActive(false); break; } }