Raised This Month: $ Target: $400
 0% 

How to get the angle direction between two entities


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 10-04-2023 , 09:50   How to get the angle direction between two entities
Reply With Quote #1

Hello guys

Trying to solve an issue where I can't exactly adjust an entity angle direction to my position.

You can see this drawing skills of mine to show you what I mean



I found a snippet in the modders community to adjust the entity angle to always face my direction but not when it comes to height difference

PHP Code:
// client
float client_pos[3];
GetClientAbsOrigin(clientclient_pos);
    
// pet
float pet_ang[3], pet_pos[3];
GetEntPropVector(entityProp_Data"m_vecOrigin"pet_pos);
GetEntPropVector(entityProp_Data"m_angRotation"pet_ang);

// adjust pet direction to my position
float distX client_pos[0] - pet_pos[0];
float distY client_pos[1] - pet_pos[1];
pet_ang[1] = (ArcTangent2(distYdistX) * 180) / 3.14
Video to show you my issue - YouTube


I Uploaded a test version, using TR_DidHit() to detect ground and attach it to it. You will notice some issues when going to different level surface.

Requires: Left4Dhooks

Video showing the test version - YouTube

If anyone has a solution, that would be great

Thanks
Attached Files
File Type: sp Get Plugin or Get Source (pet_test.sp - 58 views - 10.3 KB)
File Type: smx pet_test.smx (10.9 KB, 33 views)
__________________

Last edited by alasfourom; 10-04-2023 at 15:41.
alasfourom is offline
 



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

Forum Jump


All times are GMT -4. The time now is 05:10.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode