flymode in server package
#1

If you uses flymode filterscript or other scripts that uses it, you'll find that the camera only moves along the x/y-axis very little, when the camera is pointing completely downwards and do front/back + left/right movements.
pawn Code:
case MOVE_BACK_LEFT:
{
    X = CP[0]+(-OFFSET_X - OFFSET_Y);
    Y = CP[1]+(-OFFSET_Y + OFFSET_X);
    Z = CP[2]-OFFSET_Z;
}
case MOVE_BACK_RIGHT:
{
    X = CP[0]+(-OFFSET_X + OFFSET_Y);
    Y = CP[1]+(-OFFSET_Y - OFFSET_X);
    Z = CP[2]-OFFSET_Z;
}
case MOVE_FORWARD_LEFT:
{
    X = CP[0]+(OFFSET_X  - OFFSET_Y);
    Y = CP[1]+(OFFSET_Y  + OFFSET_X);
    Z = CP[2]+OFFSET_Z;
}
case MOVE_FORWARD_RIGHT:
{
    X = CP[0]+(OFFSET_X  + OFFSET_Y);
    Y = CP[1]+(OFFSET_Y  - OFFSET_X);
    Z = CP[2]+OFFSET_Z;
}
In the case when the camera is pointing downwards, the x and y camera vector are too small compared to the z vector, so that it moves very little on the x-y coordinate plane as compared to the z one.
I tried many methods but I still can't make a good solution (something similar to MTA's as reference).
Are there any better methods to solve the problem?
Reply
#2

Anyone?
Reply
#3

Can you post the full code? It would be easier..
Reply
#4

I'd like to try to help, but I don't quite understand what you're trying to accomplish.
Reply
#5

You can try to use the flymode filterscript in the filterscript folder of the 0.3x server package. I'll explain the problem in the video below:
[ame]http://www.youtube.com/watch?v=-8QOQdwEcic[/ame]
Examples are better than words.
Reply
#6

Okay, here's a quick solution.
pawn Code:
// new Float:a;
case MOVE_BACK_LEFT:
{
    a = -atan2(FV[1], FV[0]);
    X = CP[0]+(-OFFSET_X - OFFSET_Y)+(6000 * floatsin(a, degrees));
    Y = CP[1]+(-OFFSET_Y + OFFSET_X)+(6000 * floatcos(a, degrees));
    Z = CP[2]-OFFSET_Z;
}
case MOVE_BACK_RIGHT:
{
    a = -atan2(FV[1], FV[0]) + 180.0;
    X = CP[0]+(-OFFSET_X + OFFSET_Y)+(6000 * floatsin(a, degrees));
    Y = CP[1]+(-OFFSET_Y - OFFSET_X)+(6000 * floatcos(a, degrees));
    Z = CP[2]-OFFSET_Z;
}
case MOVE_FORWARD_LEFT:
{
    a = -atan2(FV[1], FV[0]);
    X = CP[0]+(OFFSET_X - OFFSET_Y)+(6000 * floatsin(a, degrees));
    Y = CP[1]+(OFFSET_Y + OFFSET_X)+(6000 * floatcos(a, degrees));
    Z = CP[2]+OFFSET_Z;
}
case MOVE_FORWARD_RIGHT:
{
    a = -atan2(FV[1], FV[0]) + 180.0;
    X = CP[0]+(OFFSET_X + OFFSET_Y)+(6000 * floatsin(a, degrees));
    Y = CP[1]+(OFFSET_Y - OFFSET_X)+(6000 * floatcos(a, degrees));
    Z = CP[2]+OFFSET_Z;
}
Reply
#7

This works for the original problem. However if you look forward and do the same test again, you'll find that the camera moves to the left or right a lot. The camera can't move in (at least close to) 45 degree when some key combinations like W+A and W+D is pressed.
I'm sorry for that high requirement, but I just want a good (might be perfect) one.
Reply
#8

Whops, I didn't think this through. Should be fixed now.
pawn Code:
stock GetNextCameraPosition(move_mode, Float:CP[3], Float:FV[3], &Float:X, &Float:Y, &Float:Z)
{
    // Calculate the cameras next position based on their current position and the direction their camera is facing
    static
        Float:abs_z,
        Float:angle,
        Float:OFFSET_X,
        Float:OFFSET_Y,
        Float:OFFSET_Z;
    OFFSET_X = (FV[0] * 1000.0),
    OFFSET_Y = (FV[1] * 1000.0),
    OFFSET_Z = (FV[2] * 1000.0);
    switch(move_mode)
    {
        case MOVE_FORWARD:
        {
            X = CP[0] + OFFSET_X;
            Y = CP[1] + OFFSET_Y;
            Z = CP[2] + OFFSET_Z;
        }
        case MOVE_BACK:
        {
            X = CP[0] - OFFSET_X;
            Y = CP[1] - OFFSET_Y;
            Z = CP[2] - OFFSET_Z;
        }
        case MOVE_LEFT:
        {
            X = CP[0] - OFFSET_Y;
            Y = CP[1] + OFFSET_X;
            Z = CP[2];
        }
        case MOVE_RIGHT:
        {
            X = CP[0] + OFFSET_Y;
            Y = CP[1] - OFFSET_X;
            Z = CP[2];
        }
        case MOVE_BACK_LEFT:
        {
            abs_z = floatabs(OFFSET_Z);
            angle = -atan2(FV[1], FV[0]);
            X = CP[0] + (-OFFSET_X - OFFSET_Y) + (abs_z * floatsin(angle, degrees));
            Y = CP[1] + (-OFFSET_Y + OFFSET_X) + (abs_z * floatcos(angle, degrees));
            Z = CP[2] - OFFSET_Z;
        }
        case MOVE_BACK_RIGHT:
        {
            abs_z = floatabs(OFFSET_Z);
            angle = -atan2(FV[1], FV[0]) + 180.0;
            X = CP[0] + (-OFFSET_X + OFFSET_Y) + (abs_z * floatsin(angle, degrees));
            Y = CP[1] + (-OFFSET_Y - OFFSET_X) + (abs_z * floatcos(angle, degrees));
            Z = CP[2] - OFFSET_Z;
        }
        case MOVE_FORWARD_LEFT:
        {
            abs_z = floatabs(OFFSET_Z);
            angle = -atan2(FV[1], FV[0]);
            X = CP[0] + (OFFSET_X - OFFSET_Y) + (abs_z * floatsin(angle, degrees));
            Y = CP[1] + (OFFSET_Y + OFFSET_X) + (abs_z * floatcos(angle, degrees));
            Z = CP[2] + OFFSET_Z;
        }
        case MOVE_FORWARD_RIGHT:
        {
            abs_z = floatabs(OFFSET_Z);
            angle = -atan2(FV[1], FV[0]) + 180.0;
            X = CP[0] + (OFFSET_X + OFFSET_Y) + (abs_z * floatsin(angle, degrees));
            Y = CP[1] + (OFFSET_Y - OFFSET_X) + (abs_z * floatcos(angle, degrees));
            Z = CP[2] + OFFSET_Z;
        }
    }
}
Reply
#9

Wow it works, thanks so much.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)