private void UpdatePosition(Vertex3f targetPosition, float targetRotationY) { float theta = targetRotationY + angleAroundPlayer; float offsetX = GetHorizontalDisatnace() * (float)Math.Sin(Maths.DegreeToRadian(theta)); float offsetZ = GetHorizontalDisatnace() * (float)Math.Cos(Maths.DegreeToRadian(theta)); position.x = targetPosition.x - offsetX; position.z = targetPosition.z - offsetZ; position.y = targetPosition.y + GetVerticalDisatnace(); this.yaw = 180 - (targetRotationY + angleAroundPlayer); }
private float GetVerticalDisatnace() { return(this.distanceFromPlayer * (float)Math.Sin(Maths.DegreeToRadian(pitch))); }
private float GetHorizontalDisatnace() { return(this.distanceFromPlayer * (float)Math.Cos(Maths.DegreeToRadian(pitch))); }