Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use getbonepos, aim calculations #51

Closed
Diwiasln opened this issue Sep 11, 2020 · 11 comments
Closed

how to use getbonepos, aim calculations #51

Diwiasln opened this issue Sep 11, 2020 · 11 comments
Milestone

Comments

@Diwiasln
Copy link

get bone position gets a result like get eye position

how can i fix that?
Screenshot_4
20200912022103_1

@myzarfin
Copy link

myzarfin commented Sep 12, 2020

Is there any particular reason you're using GetBonePosition over GetHitboxPosition? Hitboxes are objectively better than bones.

EDIT: As for the actual reason why it's not working, I just tested it with my edit and it looks like you're unnecessarily doing *entity->GetBonePosition(8). Remove the * and it should work just fine.

@Diwiasln
Copy link
Author

Diwiasln commented Sep 12, 2020

Is there any particular reason you're using GetBonePosition over GetHitboxPosition? Hitboxes are objectively better than bones.

EDIT: As for the actual reason why it's not working, I just tested it with my edit and it looks like you're unnecessarily doing *entity->GetBonePosition(8). Remove the * and it should work just fine.

if i romove * then
image

end i try gethitboxposition(8) same result
thanks for your answer

@myzarfin
Copy link

Is there any particular reason you're using GetBonePosition over GetHitboxPosition? Hitboxes are objectively better than bones.
EDIT: As for the actual reason why it's not working, I just tested it with my edit and it looks like you're unnecessarily doing *entity->GetBonePosition(8). Remove the * and it should work just fine.

if i romove * then
image

end i try gethitboxposition(8) same result
thanks for your answer

Not sure why it does that. I assume you can just remove the std::optional and replace it with Vector and change the corresponding entity.cpp function to match basic returns for Vector. That must have been added in a recent update; I'm being by quite a bit, just before the netvar change and I added just that over anything else. You may have to wait for qo0 to reply because I'm not familiar with std::optional.

@Diwiasln
Copy link
Author

Diwiasln commented Sep 12, 2020

i changed std::optional vector to vector

but i have a lot of error more :D

image
image

@Diwiasln
Copy link
Author

Diwiasln commented Sep 12, 2020

oh okay i fixed error (just deleted :p)

and got some result :(

Screenshot_5
Screenshot_6

and i try again gethitboxposition and again some result :(

@semidemi26
Copy link

im working with an older version and its working perfectly, has the function changed?
Vector CBaseEntity::GetBonePosition(int iBone)
{
std::array<matrix3x4_t, MAXSTUDIOBONES> arrBonesToWorld;

if (this->SetupBones(arrBonesToWorld.data(), MAXSTUDIOBONES, BONE_USED_BY_ANYTHING, 0.f))
	return arrBonesToWorld.at(iBone).at(3);

return Vector{ };

}

also gethitboxposition is not objectively better

@Diwiasln
Copy link
Author

thanks for answer

i changed getboneposition code and got some result :'(
Screenshot_8

Screenshot_7

@reaperpaster
Copy link

reaperpaster commented Sep 12, 2020

auto bonePos = entity->GetBonePosition(BONE_HEAD).value()
You need to use auto or Vector.
Btw in your screenshot you did .value() and it said Vector doesn't have value() but GetBonePosition is std::optional Vector not Vector so you probably messed up with the code.

@Diwiasln
Copy link
Author

thanks for answer

i changed code like ur comment

image

image

but same result

@rollraw
Copy link
Owner

rollraw commented Sep 12, 2020

about std::optional u can read here
so, u should check is it has value (with .has_value()) or just use .value() / .value_or(default value)
but u can notice problem isn't in getbonepos because ur calculations wrong and u should normalize calculated angle after subtract punch from it

pseudo:

QAngle angPunch = pLocal->GetPunch() * 2.0f // prefered weapon_recoil_scale instead hardcoded "2.0"
angPunch.Normalize();

QAngle angAim = M::CalcAngle(pLocal->GetEyePosition(), pEntity->GetBonePosition(BONE_HEAD).value()) - (pCmd->angViewPoint + angPunch)
angAim.Normalize()

@rollraw rollraw changed the title getbonepos dont work how to use getbonepos, aim calculations Sep 13, 2020
@rollraw
Copy link
Owner

rollraw commented Sep 13, 2020

op didnt answered for 2 days, should be fixed. closed

@rollraw rollraw closed this as completed Sep 13, 2020
@rollraw rollraw added this to the v1.0 milestone Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants