Jump to content

[SOLVED] Determining if NPC is on the ground


HughJanus
 Share

Recommended Posts

I want to check if an NPC is on the ground.

I am using the following code to get the positions of the headbone and the ground shown on the screen:

char c[40];
char c2[40];
float act = 1;
float act2 = 1;
std::string text = "Zcoord ground = ";
std::string text2 = "Zcoord head = ";

Vector3 vechead = ENTITY::GET_WORLD_POSITION_OF_ENTITY_BONE(playerPed, 21030);
float groundzcoord;
GAMEPLAY::GET_GROUND_Z_FOR_3D_COORD(vechead.x, vechead.y, vechead.z, &groundzcoord, true);
act = groundzcoord;
text = "Zcoord ground = " + std::to_string(act);
act2 = vechead.z;
text2 = "Zcoord head = " + std::to_string(act2);
strcpy(c, text.c_str());
strcpy(c2, text2.c_str());
DrawText(0.4, 0.4, c);
DrawText(0.3, 0.3, c2);

 

Unfortunately both values seem to be always 0:

zcoord.thumb.png.39b9c18a362fcf9298769e991dcb429b.png

 

 

Can someone hint me in the right direction, please?

How can I get the z coordinate of the skull (bone ID should be 21030) and from the ground?

 

 

Edit: here is the line of code that needed correcting:

 

Vector3 vechead = ENTITY::GET_WORLD_POSITION_OF_ENTITY_BONE(playerPed, PED::GET_PED_BONE_INDEX(playerPed, 21030));

 

Edited by HughJanus
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...