SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 18/02/2020, 03:57 PM   #1
Davi52
Little Clucker
 
Join Date: Sep 2018
Posts: 40
Reputation: 0
Question Looking at a point

Hey guys, sorry again for disturbing you!
How can I set my players camera looking at a point? After I freeze my character, i want it to look at a point. I tried SetPlayerCameraLookAt, but it sets my camera at the default server connecting place(on the sky). SetPlayerFacingAngle sets only the rotation of the character. How should I solve this? Thank you!
Davi52 is offline   Reply With Quote
Old 18/02/2020, 04:54 PM   #2
SiaReyes
Gangsta
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 617
Reputation: 57
Default Re: Looking at a point

https://wiki.sa-mp.com/wiki/SetPlayerCameraLookAt

Did you use SetPlayerCameraPos?
SiaReyes is offline   Reply With Quote
Old 18/02/2020, 05:22 PM   #3
Davi52
Little Clucker
 
Join Date: Sep 2018
Posts: 40
Reputation: 0
Default Re: Looking at a point

No I didnt. I want to point the camera to an object while its behind the player.
Davi52 is offline   Reply With Quote
Old 18/02/2020, 06:06 PM   #4
Radless
Little Clucker
 
Join Date: Jul 2019
Posts: 48
Reputation: 3
Default Re: Looking at a point

Code:
stock SetPlayerLookAt(playerid, Float:X, Float:Y)
{
	new Float:Px, Float:Py, Float: Pa;
	GetPlayerPos(playerid, Px, Py, Pa);
	Pa = floatabs(atan((Y-Py)/(X-Px)));
	if (X <= Px && Y >= Py) Pa	 = floatsub(180, Pa);
	else if (X < Px && Y < Py) Pa = floatadd(Pa, 180);
	else if (X >= Px && Y <= Py) Pa = floatsub(360.0, Pa);
	Pa = floatsub(Pa, 90.0);
	if (Pa >= 360.0) Pa = floatsub(Pa, 360.0);
	SetPlayerFacingAngle(playerid, Pa);
}
Radless is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mission checkpoints? [point to point][streamer] tommzy09 Scripting Help 5 23/05/2015 05:58 AM
[NEED] Car spawn point/ shop point Fantje Scripting Help 5 16/03/2015 05:21 PM
need help with a Point to Point Mission (incognito Streamer) tommzy09 Scripting Help 6 25/07/2014 12:29 AM
Calculate angle from point to point Thomas. Scripting Help 3 28/11/2011 01:22 AM
Pickup point, exit/enter point - Virtual worlds Chivava Help Archive 4 27/12/2010 02:55 PM


All times are GMT. The time now is 01:00 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.