Line of laser projection. -
Kyle - 12.02.2014
Is there a way I can detect if a player walks through a laser object?
Regards
AW: Line of laser projection. -
ElliotH - 12.02.2014
I think you can with Areas with the streamer plugin (
https://sampforum.blast.hk/showthread.php?tid=102865 )
Re: AW: Line of laser projection. -
Kyle - 12.02.2014
Quote:
Originally Posted by ElliotH
|
Thanks for
trying but that doesn't really help as it doesn't give the projection or what is required to work it out.
AW: Line of laser projection. -
ElliotH - 12.02.2014
What you can do too is to run a timer and get the position of the laser and player.. After that use trigonometric functions to check if the player is touching the beam
You need a bit math to do all the calculations
Re: Line of laser projection. -
Pottus - 12.02.2014
http://pastebin.com/f9tBPeF1
Re: Line of laser projection. -
MP2 - 12.02.2014
Projection? What on earth are you talking about? Attach a rectangle area to the object..
Quote:
Originally Posted by [uL]Pottus
|
Is that meant to put a
cylinder around the laser? Not a sphere?
Re: Line of laser projection. -
Lajko1 - 12.02.2014
Detect if is player in range of point? Detect Laser coordinates?
pawn Код:
#define MAX_LASERS 5 // your number here
pawn Код:
enum sInfo
{
sCreated,
Float:sX,
Float:sY,
Float:sZ,
sObject,
};
new LasInfo[MAX_LASERS][sInfo];
This code is if you are adding lasers with command:
pawn Код:
stock CreateLas(Float:x,Float:y,Float:z,Float:Angle)
{
for(new i = 0; i < sizeof(LasInfo); i++)
{
if(LasInfo[i][sCreated] == 0)
{
LasInfo[i][sCreated]=1;
LasInfo[i][sX]=x;
LasInfo[i][sY]=y;
LasInfo[i][sZ]=z-0.7;
LasInfo[i][sObject] = CreateObject(2899, x, y, z-0.9, 0, 0, Angle-90);
return 1;
}
}
return 0;
}
Detecting if player touched laser, maybe chance IsPlayerInRangeOfPoint(playerid,1.0 --> 0.0 ?
pawn Код:
public OnPlayerUpdate(playerid)
{
if(!IsPlayerConnected(playerid)) return 0;
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
for(new i = 0; i < sizeof(LasInfo); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 1.0, LasInfo[i][sX], LasInfo[i][sY], LasInfo[i][sZ]))
{
// What will happen next is up to you
It should be something like this... I copied this from my script where I'm placing object with command.. so try to figure out from this how it works ^^
Re: Line of laser projection. -
Pottus - 12.02.2014
Quote:
Originally Posted by MP2
Projection? What on earth are you talking about? Attach a rectangle area to the object..
Is that meant to put a cylinder around the laser? Not a sphere?
|
It defines the laser as a line p1,p2 then you just specify the sphere x, y, z and radius to check for an intersection. If you wanted to have a lot of areas then you would need to create an iterator to keep track of the areas the player is in then do the collision checks.
Re: Line of laser projection. -
Riddick94 - 12.02.2014
How about creating rectange dynamic area? I really don't know, because it will be not accurate anyway (by any way of doing it).
Re: Line of laser projection. -
Pottus - 12.02.2014
Quote:
Originally Posted by Riddick94
How about creating rectange dynamic area? I really don't know, because it will be not accurate anyway (by any way of doing it).
|
The problem with that is dynamic areas are not well suited to this application the laser detection area would have to be quite large. Not that it can't work but your going to have a problem with the player ducking / jumping over lasers or the area being too small to register.