public override void Update(float deltaTime) { Vector2 acc = CalculateAcceleration(MCentreBaseOfGravity.Position, MSatelliteBaseEntity.Position); Vector2 deltaAcc = acc * deltaTime; Vector2 adjustment = (m_orbit[m_currentOrbitIndex] - MSatelliteBaseEntity.Position) * m_adjustmentStrength; Vector2 adjustedAcc = adjustment.magnitude > 0.1f ? adjustment : adjustment + MSatelliteBaseEntity.Velocity + deltaAcc; MSatelliteBaseEntity.SetVelocity(adjustedAcc); m_currentOrbitIndex = ++m_currentOrbitIndex % m_orbit.Count; }
public override void Update(float deltaTime) { base.Update(deltaTime); float currentRotationAngleZ = MSatelliteBaseEntity.Rotation.eulerAngles.z; if (Input.GetKey(KeyCode.A)) { MSatelliteBaseEntity.SetRotation( Quaternion.AngleAxis(currentRotationAngleZ + m_turnAngle, Vector3.forward)); } else if (Input.GetKey(KeyCode.D)) { MSatelliteBaseEntity.SetRotation( Quaternion.AngleAxis(currentRotationAngleZ - m_turnAngle, Vector3.forward)); } if (Input.GetKey(KeyCode.Space)) { MSatelliteBaseEntity.SetVelocity(MSatelliteBaseEntity.Velocity + (Vector2)(MSatelliteBaseEntity.Rotation * m_acceleration)); } }