I have a large Problem =(
I am trying to orient a Camera in 3D space so that it
follows the player (Third Person). The player has a
Rotation Value that determines which way it is facing,
and how to move it around. To do this, i have initialized
a lookup table with 360 sin and cos values. That looks
like this:
For forward and backward movment:Code:Const RAD = 180 / 3.14159 For i = 0 to 360 Theta = i * RAD Array(i).X = Cos(Theta) Array(i).Y = Sin(Theta) Next i
For left and right, I just add or subtract 1 from theCode:If KeyUp Then CurrPos.X = CurrPos.X + Array(Rotation).X CurrPos.Z = CurrPos.Z - Array(Rotation).Y End If If KeyDown Then CurrPos.X = CurrPos.X - Array(Rotation).X CurrPos.Z = CurrPos.Z + Array(Rotation).Y End If
Rotation value.
To Orient the camera, the code is:
If Ive done all of my math right, subtracting 180 from myCode:X = Abs(Rotation - 180) CameraPos.X = CurrPos.X - CamDistFromPlayer * Array(X) CameraPos.Y = CurrPos.Y + 4 CameraPos.Z = CurrPos.Z - CamDistFromPlayer * Array(X)
Rotation should give me the opposite angle. But, when I
run the code, when I push Up or Down, I go sideways.
Left and Right still rotate. Hopefully someone will come
up with the answer. Ive been working on this for about
5 days now =(
Thanks Much




Reply With Quote