VectorDot(); I can't express how much I love you, for your use in caluculating an angle, for your use in orientating things properly, for your use for anything imainable.
Here's something I whipped up while working on my menu camera code:
What this does, is move the camera thing, which is attached to the DPlayer thing. DPlayer is a dummy actor that is rotated according to the menu cursor co-ords, and how far away from the center the cursor is. (Flight mechanics like freelancer)
Well, this is the camera code that orientates the camera properly for a 3rd person camera, when the thing the camera should be following is rotating all around the place. (dunno how 1st person reacts to being rotated all over)
Thank you VectorDot(), I'd have man babies with you, but you are a 0's and 1's, and I am flesh. :p
[Theres a slight bug where if the thing is attached, and you rotate, due to 0x8 attachment, the camera doesn't align itself to the LVec of the player, easily compensated for though. The SetThingVel() is pretty much in vain I do believe, I was using that before I stuck in the 0x8 attachment.]
Here's something I whipped up while working on my menu camera code:
Code:
//Position that the camera will keep behind the player along LVec thanks to 0x8 attachment. Position_Vec = VectorSet(0.0, -0.4, 0.14); CamYPos=VectorScale(GetThingLVec(DPlayer), -0.4); CamZPos=VectorScale(GetThingUVec(DPlayer), 0.14); NewCamPos=VectorAdd(CamYPos, CamZPos); NewCamPos=VectorAdd(GetThingPos(DPlayer), NewCamPos); CamNewDist=VectorDist(NewCamPos, GetThingPos(FlightCamera)); SetThingVel(FlightCamera, VectorScale(VectorSub(NewCamPos ,GetThingPos(FlightCamera)), CamNewDist)); DotP=VectorDot(GetThingUVec(FlightCamera), GetThingLVec(DPlayer)); DotY=VectorDot(GetThingLVec(FlightCamera), GetThingRVec(DPlayer)); TempVec=VectorAdd(GetThingUVec(FlightCamera), GetThingPos(FlightCamera)); TempVec=VectorScale(VectorSub(TempVec, GetThingPos(FlightCamera)), -1); DotR=VectorDot(TempVec, GetThingRVec(DPlayer)); DotVector=VectorSet(360*DotP, 360*DotY, 360*DotR); SetThingRotVel(FlightCamera, DotVector);
What this does, is move the camera thing, which is attached to the DPlayer thing. DPlayer is a dummy actor that is rotated according to the menu cursor co-ords, and how far away from the center the cursor is. (Flight mechanics like freelancer)
Well, this is the camera code that orientates the camera properly for a 3rd person camera, when the thing the camera should be following is rotating all around the place. (dunno how 1st person reacts to being rotated all over)
Thank you VectorDot(), I'd have man babies with you, but you are a 0's and 1's, and I am flesh. :p
[Theres a slight bug where if the thing is attached, and you rotate, due to 0x8 attachment, the camera doesn't align itself to the LVec of the player, easily compensated for though. The SetThingVel() is pretty much in vain I do believe, I was using that before I stuck in the 0x8 attachment.]
-Hell Raiser