SA-MP Forums Archive
[Include] Fly Camera - Originally by Kalcor - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] Fly Camera - Originally by Kalcor (/showthread.php?tid=589766)



Fly Camera - Originally by Scott - Gammix - 22.09.2015

Fly Camera


This is an edited version of Kalcor's flymode filterscript. Those who don't know the general idea, this include let you toggle flying camera (a spectating screen which can be controlled with mouse and key combinations).

What's new? Stocks
pawn Код:
SetPlayerCamera(playerid, type = 1);
Read the above section for types information.

pawn Код:
SetPlayerCameraSpeed(playerid, Float:speed);
The camera speed at which the fly mode will run.
(General speed = 50.0)

pawn Код:
Float: GetPlayerCameraSpeed(playerid);
Returns the player camera speed (floating unit).

And there is this callback which will be called everytime when the player moves his/her camera (not doesn't support rotation detection)
pawn Код:
public OnPlayerCameraUpdate(playerid, Float:oldx, Float:oldy, Float:oldz, olddir, Float:newx, Float:newy, Float:newz, newdir)
Dowload
The github repo:

https://github.com/Gammix/Fly-Camera


Where to use?
Here are few ideas that can be generated by this:


Re: Fly Camera - Originally by Kalcor - ExTaZZ69 - 22.09.2015

Another nice script from you. Keep on!


Re: Fly Camera - Originally by Kalcor - Lordzy - 22.09.2015

"Flymode" filterscript was actually written by h02 AKA Scott.


Re: Fly Camera - Originally by Kalcor - SecretBoss - 22.09.2015

Nice idea, thanks again


Re: Fly Camera - Originally by Kalcor - Stanford - 22.09.2015

Amazing keep up the good work mate!


Re: Fly Camera - Originally by Kalcor - n0minal - 22.09.2015

Very nice Mr.Gammix, keep it up


Re: Fly Camera - Originally by Kalcor - Gammix - 23.09.2015

Update - 23/09/2015 Done basically for those who want acceleration for camera and use things related to camera position updates.


Re: Fly Camera - Originally by Kalcor - jlalt - 23.09.2015

Good job!


Re: Fly Camera - Originally by Kalcor - X337 - 23.09.2015

Good job gammix, another amazing script from you.


Re: Fly Camera - Originally by Kalcor - Crayder - 23.09.2015

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Update - 23/09/2015
  • Added new stock (get player camera's movement speed)
    pawn Код:
    Float: GetPlayerCameraSpeed(playerid);
  • Added new callback (called whenever player camera changes position
    pawn Код:
    public OnPlayerCameraUpdate(playerid, Float:oldx, Float:oldy, Float:oldz, olddir, Float:newx, Float:newy, Float:newz, newdir)
Done basically for those who want acceleration for camera and use things related to camera position updates.
The suggestions would still be better... D:

It's fine though, I can manage...

Your libraries are always promising.


Re: Fly Camera - Originally by Kalcor - Crayder - 26.09.2015

Suggestion:
SetPlayerCameraPos (hooked, if the player is in flymode set the object's position instead)

EDIT: In the old flymode we could set the object position and it would work. I just tried that with this and it locks the camera above the mansion.




Other Suggestion: Just more script-wise manipulation. I was hoping for more of something like this, but with flymode.
You could modify the SetPlayerCamera function to allow position and lookat parameters, that would be perfectly fine.

I tried doing it like this: https://github.com/Crayder/Fly-Camer...ter/flycam.inc
But that doesn't allow the camera to move.


Re: Fly Camera - Originally by Kalcor - Gammix - 27.09.2015

Quote:
Originally Posted by Crayder
Посмотреть сообщение
Suggestion:
SetPlayerCameraPos (hooked, if the player is in flymode set the object's position instead)

EDIT: In the old flymode we could set the object position and it would work. I just tried that with this and it locks the camera above the mansion.




Other Suggestion: Just more script-wise manipulation. I was hoping for more of something like this, but with flymode.
You could modify the SetPlayerCamera function to allow position and lookat parameters, that would be perfectly fine.

I tried doing it like this: https://github.com/Crayder/Fly-Camer...ter/flycam.inc
But that doesn't allow the camera to move.
Actually you can use the native simultaneously after using SetPlayerCamera.

If your code doesn't work, that maybe because of OnPlayerUpdate, due to regular checks done there. Maybe this works:
pawn Код:
stock Cam_SetPlayerCameraPos(playerid, Float:x, Float:y, Float:z) {
    if (g_FlyMode[playerid][flyType] != 0) {
        new
            iFlyType = g_FlyMode[playerid][flyType]
        ;
        g_FlyMode[playerid][flyType] = 0;

        StopDynamicObject(g_FlyMode[playerid][flyObject])
        SetDynamicObjectPos(g_FlyMode[playerid][flyObject], x, y, z);
       
        g_FlyMode[playerid][flyType] = iFlyType;
       
        return true;
    }
    else {
        return SetPlayerCameraPos(playerid, x, y, z);
    }
}
#if defined _ALS_SetPlayerCameraPos
    #undef SetPlayerCameraPos
#else
    #define _ALS_SetPlayerCameraPos
#endif
#define SetPlayerCameraPos Cam_SetPlayerCameraPos
So You can perform position after the main stock:
pawn Код:
SetPlayerCamera(playerid, 1);
SetPlayerCameraPos(playerid, ...);
Similar can be made for SetPlayerCameraLookAt.


Re: Fly Camera - Originally by Kalcor - Crayder - 27.09.2015

Still the same problem. It takes me to the beach and I can't move or rotate the camera.

I updated the code again on my GH. Here is what I did to test it:
pawn Код:
SetPlayerCamera(playerid, 1);
    SetPlayerCameraPos(playerid, 0.0, 0.0, 20.0);
    SetPlayerCameraLookAt(playerid, 20.0, 20.0, 0.0);



Re: Fly Camera - Originally by Kalcor - Richie© - 23.01.2016

It looked good, but it dosent work for me.
It just put me in spectate mode like im speccing nobody, im using simple code to toggle this:

Код:
CMD:flycam(playerid, params[])
{
    if(PVar[playerid][pAdminLVL] != 69) return CANTUSECMD
    
	if(UsingFlyCam[playerid] == false)
	{
	    UsingFlyCam[playerid] = true;
	    SetPlayerCamera(playerid, 1);
	    ShowInfoForPlayer(playerid, "~g~Flycam enabled!", 3000);
	}
	else
	{
	    UsingFlyCam[playerid] = false;
	    SetPlayerCamera(playerid, 0);
	    ShowInfoForPlayer(playerid, "~r~Flycam disabled!", 3000);
 	}
 	return 1;
}
Edit: It got solved when i changed from streamer to player objects.


Re: Fly Camera - Originally by Kalcor - Jeroen52 - 14.02.2018

I have the issue that the free camera flying is stuck after the distance that equals to the drawdistance of the object.

Is there any way to fix this?

Edit: After hours I have found the issue after some really good thinking what I have just written down, and it can be resolved via a single line. Will make multiple merge requests tomorrow since I'm tired right now.


Re: Fly Camera - Originally by Kalcor - Chaprnks - 25.08.2018

What exactly is improved/changed from the original one?