void LateUpdate() { if (Target != null) { CachedTransform.LookAt(Target, Vector3.up); } }
protected virtual void Update() { if (m_startTime != -1) { // Figure out the current normal. m_currentNormal = GetMovementNormal(); // Figure out where to move to. m_nextPos = GetPositionAlongArc(m_currentNormal); // Face our movement direction. CachedTransform.LookAt(m_nextPos); // Add a rotational offset. transform.Rotate(GetRotationOffset()); // Perform the movement. transform.position = m_nextPos; // If we are done, destroy ourselves! if (Time.time > m_startTime + m_duration) { Hit(); } } }
protected override void AddRoadNeighbor(AbstractTile tile) { base.AddRoadNeighbor(tile); if (RoadNeighbors.Count > 1) { return; } CachedTransform.LookAt(tile.CachedTransform, CachedTransform.up); }
/// <summary> /// 强制移动 /// </summary> public virtual void OnForceToMove(MoveCommand ev) { StopPathFinding(); Vector3 delta = ev.Delta; int speed = Attrbute.GetValue(AttributeType.Speed); CachedTransform.LookAt(new Vector3(CachedTransform.position.x + delta.x, CachedTransform.position.y, CachedTransform.position.z + delta.y)); m_CharacterController.SimpleMove(m_CharacterController.transform.forward * speed); this.m_AnimController.Play("run", null, true); }
public virtual void SetTarget(ActorBase actor) { if (actor == null) { m_Target = null; return; } if (m_Target == actor) { return; } m_Target = actor; CachedTransform.LookAt(m_Target.CachedTransform); }
protected void LookAtEnemy() { if (m_Target == null || m_Target.IsDead || !IsEnemy(m_Target) || m_Target.CheckActorState(ActorStateType.IsStealth)) { m_Target = null; } ActorBase enemy = GetNearestEnemy(m_ActorAI.WaringDist); this.SetTarget(enemy); if (m_Target != null) { CachedTransform.LookAt(new Vector3(m_Target.Pos.x, Pos.y, m_Target.Pos.z)); } }
protected override void AddRiverNeighbor(AbstractTile tile) { base.AddRiverNeighbor(tile); if (RiverNeighbors.Count >= 3) // led to a better effect at the time { return; } CachedTransform.LookAt(tile.CachedTransform, CachedTransform.up); // Get a random boolean to randomly rotate 180° bool shouldRotate = RandomUtil.RandomBool(); if (shouldRotate) { CachedTransform.Rotate(CachedTransform.up, 180.0f); } }
protected override void AddRoadNeighbor(AbstractTile tile) { base.AddRoadNeighbor(tile); if (RoadNeighbors.Count > 1) { return; } bool shouldRotate = CachedTransform.DirectionIsFacingTransform(Direction.Forward, tile.CachedTransform) || CachedTransform.DirectionIsFacingTransform(Direction.Right, tile.CachedTransform); CachedTransform.LookAt(tile.CachedTransform, CachedTransform.up); if ((GridPosition.x + GridPosition.y & 1) == 0) { shouldRotate ^= true; } if (shouldRotate) { CachedTransform.Rotate(CachedTransform.up, 180.0f); } }
/// <summary> /// 转向 /// </summary> public virtual void OnTurnTo(TurnToCommand ev) { Vector3 pos = new Vector3(ev.LookDirection.x, CachedTransform.position.y, ev.LookDirection.z); CachedTransform.LookAt(pos); }
private void OnEnable() { CachedTransform.LookAt(AppManager.Game.Player.CachedTransform); _collisionChecker.transform.eulerAngles = _bulletSpriteTargetAngle; }