Freeze Z coordinate
#1

Hello, I'm trying to freeze Z (height) and I want peoples opinion on the best way to do it. Currently I am doing it like this:

Код:
forward OneHalfSecond();
public OneHalfSecond()
{
	for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(gPlayer[i][Freeze_Z] == 1)
            {
                new Float:curX,
                    Float:curY,
                    Float:curZ;
                    
				GetPlayerPos(i, curX, curY, curZ);
                SetPlayerPos(i, curX, curY, gPlayer[i][Freeze_Z_Amount]);
			}
        }
    }
}
But obviously it's annoying having the screen jump every 1/2 second. Is there a way to prevent the player from falling at all or is this the only way?

Thanks.
Reply
#2

up
.
.
Reply
#3

Try TogglePlayerControllable?
Reply
#4

Try a combination of freezing the player and changing their positions when keys are pressed (access GetPlayerKeys in OnPlayerUpdate). This doesn't allow them to change camera views but then again keeps the player from falling and annoying resets once a half-second.
Reply
#5

Yeah this isn't exactly what I want, if anyone knows some hackey way to do this that will allow the camera to move through only scripting or a workaround, please post.

Thanks for suggestions.
Reply
#6

In a frequent timer:
pawn Код:
SetPlayerVelocity(playerid, 0.0, 0.0, 0.01);
Increase '0.01' if player is still sinking.
Reply
#7

Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
In a frequent timer:
pawn Код:
SetPlayerVelocity(playerid, 0.0, 0.0, 0.01);
Increase '0.01' if player is still sinking.
He wants the player to move about the x and y axis so wouldn't it be better to:

pawn Код:
new Float: fVel[3];

GetPlayerVelocity(playerid, fVel[0], fVel[1], fVel[2]);
#pragma unused fVel[2]
SetPlayerVelocity(playerid, fVel[0], fVel[1], 0.01);
Reply
#8

Thanks for suggestions everyone.

Here's what I want to do. I've put together a script to change coordinates (simply with SetPlayerPos) when a certain key is held. It work's pretty well if the player is on the ground, assuming he can change facing angle. What would be nice is some math that will convert my camera facing angle to player facing angle. The solutions posted so far don't work for my purpose because the player can't change angles since he still falls very slowly.

Thanks.
Reply
#9

Quote:
Originally Posted by SA.
Посмотреть сообщение
Thanks for suggestions everyone.

Here's what I want to do. I've put together a script to change coordinates (simply with SetPlayerPos) when a certain key is held. It work's pretty well if the player is on the ground, assuming he can change facing angle. What would be nice is some math that will convert my camera facing angle to player facing angle. The solutions posted so far don't work for my purpose because the player can't change angles since he still falls very slowly.

Thanks.
pawn Код:
new
    Float: fCVX,
    Float: fCVY,
    Float: fAngle
;
GetPlayerCameraFrontVector(playerid, fCVX, fCVY, fAngle);
fAngle = atan2(fCVY, fCVX) - 90.0;

// SetPlayerFacingAngle(playerid, fAngle);
Reply
#10

Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
pawn Код:
new
    Float: fCVX,
    Float: fCVY,
    Float: fAngle
;
GetPlayerCameraFrontVector(playerid, fCVX, fCVY, fAngle);
fAngle = atan2(fCVY, fCVX) - 90.0;

// SetPlayerFacingAngle(playerid, fAngle);
This is exactly what I meant, thanks RyDeR and everyone else.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)