PLOT :
I have been developing a game where the player falls down on Y axis and the camera is a Top-Down view camera. The camera, player (main character in the game) movements etc. have all been implemented based off the idea/notion that the player is falling down Y axis. Hence I used to feed in the vectors based of it. The player is always acted upon gravity.
DESIGN CHANGE :
Now after all these months of developing it, I am changing the design. Now the player who was falling down, upon reaching the ground is going to take off and fly parallel to the ground
PROBLEM :
As I am changing the entire scenario, it creates a complication with vectors I used to feed in for the camera and player. Also due the constraint that the experience should be exactly similar to that off the "falling towards the ground" I have to change the gravity accordingly. Now how do I accomplish this when I have vectors all over the place based off the top down view. Please forgive if I am confusing you here. Give me a min.
To break it into the most primitive segment - I input Vector A, B etc to the camera and the player when the gravity is (0,-1,0). Now if I change the gravity to (1,0,0), how should I change the Vector A, B etc. Is there a way to formulate the Vectors A, B etc when I know the gravity has been shifted from (0,-1, 0) to (1,0,0). All the vectors are normalized. If you ask me the relationship of Vector A, B etc with the gravity (0,-1,0) - I have to say there is no relationship. As it was a game, I supplied the Vectors on how I need the Player and Camera's to work.
CODE :
// The required Force applied in Flap mode
void ForceToBeApplied()
{
//HORIZONTAL FORCE
if(!HNEXT)
{
rigidbody.AddRelativeForce((Vector3.right) * DeltaTime * LeftDrag * 3);
if(LeftDrag < 400)
LeftDrag += ToTarget(DefaultDrag,TurnSine);
rigidbody.AddForce(2,(-LeftDrag/50),0);
}
if(HNEXT)
{
rigidbody.AddRelativeForce((-Vector3.right) * DeltaTime * RightDrag * 3);
if(RightDrag < 400)
RightDrag += ToTarget(DefaultDrag, TurnSine);
rigidbody.AddForce(-2,(-RightDrag/50),0);
}
//VERTICAL FORCE
if(!VNEXT)
{
rigidbody.AddRelativeForce((Vector3.forward) * DeltaTime * UpDrag * 3);
if(UpDrag < 400)
UpDrag += ToTarget(DefaultDrag,TurnSine);
rigidbody.AddForce(0, (-UpDrag/50),-2);
}
if(VNEXT)
{
rigidbody.AddRelativeForce((-Vector3.forward) * DeltaTime * DownDrag * 3);
if(DownDrag < 400)
DownDrag += ToTarget(DefaultDrag, TurnSine);
rigidbody.AddForce(0,(-DownDrag/50),2);
}
}
IF you happen to look into the above module, I add force to the rigidbody. Those forces were added when the gravity was (0,-1,0). Now if I change my gravity to (say) (1,0,0), how should I change the forces applied to the rigidbody.
TYPE OF APPROACH I THINK : What if I could create a static class which could take those vectors and convert them to equivalent vectors for the current gravitational force.
Simple Diagrammatic Expression of The Problem :
I hope I am clear in the problem I am facing.
Thank you..