private void LateUpdate() { var camGroundPos = GroundPos.Under(transform.position); var targetGroundPos = GroundPos.Under(m_Targets[m_Index].Position); var perp = Vector3.Cross(targetGroundPos - camGroundPos, Vector3.up).normalized; var direction = (camGroundPos - targetGroundPos).normalized; var newCamPos = targetGroundPos + direction * m_Distance + perp * m_CamOffset.x + Vector3.up * m_CamOffset.y; transform.position = Vector3.SmoothDamp(transform.position, newCamPos, ref m_MoveVelo, m_MoveDamp); var newLookPos = targetGroundPos + perp * m_LookOffset.x + Vector3.up * m_LookOffset.y; m_LookPos = Vector3.SmoothDamp(m_LookPos, newLookPos, ref m_LookVelo, m_LookDamp); transform.LookAt(m_LookPos); if (Input.GetKeyDown(KeyCode.Space)) { m_Index = (m_Index + 1) % m_Targets.Length; } }
public override void Initialize() { transform.position = GroundPos.Under(transform.position) + Vector3.up; m_PrevActions = new float[c_NumActions]; m_DecisionInterval = GetComponent <DecisionRequester>().DecisionPeriod; m_GroundDetectors = GetComponentsInChildren <GroundDetector>(); m_AntPhysics = GetComponentInChildren <AntPhysics>(); m_AntPhysics.Initialize(); }
public void RandomizePosition() { Vector2 p = Random.insideUnitCircle * m_RandomPositionRadius; transform.position = GroundPos.Under(m_DefPos + new Vector3(p.x, 0, p.y)); }