Angles
#1

Hi, how would it be possible to get a player's and target's angle and check if player is in front of target or player is behind the target? I want to apply different animations when player gets shot either in back or front but I can't understand how to do it.

like that: https://gyazo.com/94ce8d9cd3503172a1889147d65cbef6
Reply
#2

GetPlayerFacingAngle and using trigonometry... You know, that thing that you didn't learn, in those classes because you thought it wasn't "needed". xD
Reply
#3

no i was never learning that i think and my mind blowns up when i think about it, i kinda know how to do it but i don't at the same time lmao
Reply
#4

I got told in school I'd only ever pass English, but in the end failed English, passed Maths and Science, and most of my class time in both of those classes was sleeping in the back of the class.
Reply
#5

lol ok, but do u know how to make it? anyone?
Reply
#6

PHP код:
new Float:x,Float:y,Float:z,
    
Float:tx,Float:ty,Float:tz,
    
Float:rx,Float:rz,Float:offset_rz;
GetPlayerPos(center_playerid,x,y,z);
GetPlayerFacingAngle(center_playerid,offset_rz);
GetPlayerPos(circle_playerid,tx,ty,tz);
GetRotationFor2Point3D(x,y,z,tx,ty,tz,rx,rz);
CompRotationFloat(rz-offset_rz,rz);
//compare rz 


3DTryg:
https://sampforum.blast.hk/showthread.php?tid=591010
Reply
#7

Erm, would it be possible without any additional includes?
Reply
#8

Quote:
Originally Posted by AbyssMorgan
Посмотреть сообщение
PHP код:
new Float:x,Float:y,Float:z,
    
Float:tx,Float:ty,Float:tz,
    
Float:rx,Float:rz,Float:offset_rz;
GetPlayerPos(center_playerid,x,y,z);
GetPlayerFacingAngle(center_playerid,offset_rz);
GetPlayerPos(circle_playerid,tx,ty,tz);
GetRotationFor2Point3D(x,y,z,tx,ty,tz,rx,rz);
CompRotationFloat(rz-offset_rz,rz);
//compare rz 


3DTryg:
https://sampforum.blast.hk/showthread.php?tid=591010
Uh, yea, also could you give an example with OnPlayerGiveDamage? I don't really understand this thing. If It's the only way to do it then I will use it. Will I need any plugins?
Reply
#9

In the thread it says it only needs the plugins for the more advanced portions. Check that thread, it seems like it shouldn't need anything extra.

PHP код:
GetRotationFor2Point3D(x,y,z,tx,ty,tz,rx,rz); 
CompRotationFloat(rz-offset_rz,rz); 
Those are the 2 functions that the include is needed for. They don't seem like they are under the plugin required listings.
Reply
#10

3DTryg. It does not require plug-ins.

PHP код:
public OnPlayerGiveDamage(playeriddamagedidFloat:amountweaponidbodypart){
    if(
damagedid != INVALID_PLAYER_ID){
        new 
Float:x,Float:y,Float:z
            
Float:tx,Float:ty,Float:tz
            
Float:rx,Float:rz,Float:offset_rz
        
GetPlayerPos(damagedid,x,y,z); 
        
GetPlayerFacingAngle(damagedid,offset_rz); 
        
GetPlayerPos(playerid,tx,ty,tz); 
        
GetRotationFor2Point3D(x,y,z,tx,ty,tz,rx,rz); 
        
CompRotationFloat(rz-offset_rz,rz); 
        
//compare rz
        
if((rz >= 0.0 && rz <= 45.0) || (rz >= 315.0 && rz <= 360.0)){
            
//front of skin
            
        
} else if(rz >= 45.0 && rz <= 135.0){
            
//right of skin
            
        
} else if(rz >= 135.0 && rz <= 225.0){
            
//back of skin
        
} else if(rz >= 225.0 && rz <= 315.0){
            
//left of skin
            
        
}
    }
    
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)