Camerascreen & -movement
#1

Alright, well I get several questions which could assist me with a tutorial for new players of a server.

At first I would like to know how I can create something like a camerascreen for a tutorial like here. There you can see the LSPD without any Player infront of you. What kind of commands do I need for that?

Second: I'd like to know how it's possible to make a movement of a camera if I got the screen of question one. Like for example the camera slowly flys around the LSPD building.

Third: How is it possible to make an image changing slowly like it slowly looses its oppacity? Let's say you got the image of the LSPD and now I want to change it to an image of the Cityhall. How can I make that it's not a fast changing of the image but a slow one like slowly the screen gets black and afterwards slowly the black screen disappears and looses its oppacity that the new image is visible?
Reply
#2

Quote:
Originally Posted by GiS
Посмотреть сообщение
Alright, well I get several questions which could assist me with a tutorial for new players of a server.
You are welcome

Quote:
Originally Posted by GiS
Посмотреть сообщение
At first I would like to know how I can create something like a camerascreen for a tutorial like here.
That are two black textdraw boxes, shouldnt be hard to make

Quote:
Originally Posted by GiS
Посмотреть сообщение
There you can see the LSPD without any Player infront of you. What kind of commands do I need for that?
Just set the player into an unique virtual world, I would recommand (playerid + 1) since 0 is the default world and playerid 0 shouldnt see that
Dont forget to set the world to 0 again if he spawns

Quote:
Originally Posted by GiS
Посмотреть сообщение
Second: I'd like to know how it's possible to make a movement of a camera if I got the screen of question one. Like for example the camera slowly flys around the LSPD building.
For that you only need the basic of trigonometry, lets say the camera should fly in a circle around the point

We create a function which call it self again till something happens (as example if the player spawns)
pawn Код:
forward TRotate(playerid, Float: X, Float: Y, Float: Z, Float: R, Float: A);
public TRotate(playerid, Float: X, Float: Y, Float: Z, Float: R, Float: A) {
    if(GetPlayerState(player) == PLAYER_STATE_WASTED) {
        SetCameraPos(playerid, X + (floatcos(A, degrees) * R), Y + (floatsin(A, degrees) * R), Z + 10);
        SetTimerEx("TRotate", 100, false, "ifffff", playerid, X, Y, Z, R, A + 1.0);
    }
}
Quote:
Originally Posted by GiS
Посмотреть сообщение
Third: How is it possible to make an image changing slowly like it slowly looses its oppacity? Let's say you got the image of the LSPD and now I want to change it to an image of the Cityhall. How can I make that it's not a fast changing of the image but a slow one like slowly the screen gets black and afterwards slowly the black screen disappears and looses its oppacity that the new image is visible?
For that you just create a function which creates a black box with 0 opacity and slowly change it to full opacity
And than change the camera pos / look at and afterwards let it go to 0 opacity again
pawn Код:
stock StartChange(playerid, Float: X, Float: Y, Float: Z, Float: cX, Float: cY, Float: cZ) {
    new Text:gText = TextDrawCreate(0.0, 0.0, "_");
    TextDrawUseBox(gText, true);
    cbOpacity(playerid, gText, 0, false, X, Y, Z, cX, cY, cZ);
}
pawn Код:
forward cbOpacity(playerid, Text:tText, opacity, bool: down, Float: X, Float: Y, Float: Z, Float: cX, Float: cY, Float: cZ);
public cbOpacity(playerid, Text:tText, opacity, bool: down, Float: X, Float: Y, Float: Z, Float: cX, Float: cY, Float: cZ) {
    TextDrawBoxColor(tText, opacity);
    if(down) {
        if(--opacity <= 0) {
            TextDrawDestroy(tText);
            return ;
        }
    } else {
        if(++opacity >= 255) {
            SetTimerEx("cbOpacity", 100, false, "iiib", playerid, _:tText, opacity, true);
            SetPlayerCameraPos(playerid, cX, cY, cZ);
            SetPlayerCameraLookAt(playerid, X, Y, Z);
            return;
        }
    }
    SetTimerEx("cbOpacity", 100, false, "iiib", playerid, _:tText, color, visible, X, Y, Z, cX, cY, cZ);
}
Everything not tested, just written out of fun
Reply
#3

Alright, that helps already a lot. After studying a lot of what you did in wiki and reading it several times there are still some questions about it:

pawn Код:
if(down) { // What do you mean with 'down'? What do you ask here for?
        if(--opacity <= 0) { // Where did you define --opacity and what is it?
            TextDrawDestroy(tText);
            return ;
        }
    } else {
        if(++opacity >= 255) { // Where did you define ++opacity and what is it?
            SetTimerEx("cbOpacity", 100, false, "iiib", playerid, _:tText, opacity, true);
            SetPlayerCameraPos(playerid, cX, cY, cZ);
            SetPlayerCameraLookAt(playerid, X, Y, Z);
            return;
        }
    }
pawn Код:
SetCameraPos(playerid, X + (floatcos(A, degrees) * R), Y + (floatsin(A, degrees) * R), Z + 10);
// Shouldn't that be SetPlayerCameraPos and what actually happens here?
Thanks for your time.
Reply
#4

Quote:
Originally Posted by GiS
Посмотреть сообщение
pawn Код:
SetCameraPos(playerid, X + (floatcos(A, degrees) * R), Y + (floatsin(A, degrees) * R), Z + 10);
// Shouldn't that be SetPlayerCameraPos and what actually happens here?
Yeah it should be SetPlayerCameraPos

X, Y and Z are the coordinates of the center (the 0 in the image) in your example it is the building



The code repeats itself till the state of the player isnt PLAYER_STATE_WASTED
And with each tick it increase the angle by one

pawn Код:
SetTimerEx("TRotate", 100, false, "ifffff", playerid, X, Y, Z, R, A + 1.0);
We know that cos(Angle) gets the x offset and sin(Angle) the y offset for the circle

And we know that cos and sin get always a value between [-1;1] (cosІ + sinІ = 1 [pythagorean])

To get our circle with the correct radius we just multiply the cos / sin with our wanted amplitude

=> X = CENTER_X + cos(Angle) * Radius; Y = CENTER_Y + sin(Angle) * radius;

And Z = CENTER_Z + 10 for a nice camera position

Quote:
Originally Posted by GiS
Посмотреть сообщение
pawn Код:
if(down) { // What do you mean with 'down'? What do you ask here for?
        if(--opacity <= 0) { // Where did you define --opacity and what is it?
            TextDrawDestroy(tText);
            return ;
        }
    } else {
        if(++opacity >= 255) { // Where did you define ++opacity and what is it?
            SetTimerEx("cbOpacity", 100, false, "iiib", playerid, _:tText, opacity, true);
            SetPlayerCameraPos(playerid, cX, cY, cZ);
            SetPlayerCameraLookAt(playerid, X, Y, Z);
            return;
        }
    }
++variable / variable++ are in pawn the same like --variable / variable--
variable ++ = variable + 1, variable -- = variable - 1
(the operator can be found in float.inc)

Thats the main function where we create our temporary textdraw
pawn Код:
stock StartChange(playerid, Float: X, Float: Y, Float: Z, Float: cX, Float: cY, Float: cZ) {
    new Text:gText = TextDrawCreate(0.0, 0.0, "_");
    TextDrawUseBox(gText, true);
    cbOpacity(playerid, gText, 0, false, X, Y, Z, cX, cY, cZ);
}
Here you can see that the parameter down is set on false (down is only a flag, you could it call how you want)

First is that part executed till it reach 255 (0xFF) the full opacity

pawn Код:
//
        if(++opacity >= 255) { // Where did you define ++opacity and what is it?
            SetTimerEx("cbOpacity", 100, false, "iiib", playerid, _:tText, opacity, true);
            SetPlayerCameraPos(playerid, cX, cY, cZ);
            SetPlayerCameraLookAt(playerid, X, Y, Z);
            return;
        }
Than if its fully dark we change the camera position
And we call now our other code, so it vanish again
pawn Код:
"iiib", playerid, _:tText, opacity, true)
down is now set to true and this code is executed
pawn Код:
//
        if(--opacity <= 0) { // Where did you define --opacity and what is it?
            TextDrawDestroy(tText);
            return ;
        }
with that the code will stop repeating itself
at least we destroy our temporary textdraw => end

Good luck
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)