• Help calculating Angles
    2 replies, posted
Hi forum. Im working on a "generic" version of McCree's abilities from overwatch and to be honest i never worked with rotation angles before in gmod, i know which one is which (p,y,r) but i dont know how to work with their functions property. What i gotta do for Dead Eye is point my r_hand bone to the target im shooting (like how he does in overwatch), but i have no idea how to calc the right angles for it. I tried getting the angle in the same way some people does to point the players EyeAngles to the target (targetpos - referencepos):angle but that didnt worked as expected. I recorded with bullet time on so you guys can see how it is changing with what im currently trying. My goal is actually make as close as possible to Overwatch, point to the target (not as hard as it is on the video) and point rightly, not just snaping to the center, left or right of the screen. When looking to this direction of the world it seems to be working quite right: https://files.facepunch.com/forum/upload/185744/42d4d090-8041-44a9-a7a1-1dbc8f30e821/Deadeye.mp4 But when i look to any other direction this happens: https://files.facepunch.com/forum/upload/185744/c4c231b6-2d68-4c29-8884-c07111d76946/Deadeye1.mp4 Here is my snip: (the function GetTargetPos is returning either the targets eye or head bone or its center position) function DeadEye_DirectArm() local ply = LocalPlayer() local vm = ply:GetViewModel() local weapon = ply:GetActiveWeapon() if !weapon.IsOverwatch then return end local h_b = vm:LookupBone(weapon.R_Hand_Bone) local h_bp, h_ba = vm:GetBonePosition(h_b) local a_zero = Angle(0,0,0) local tg = weapon.DETarget if weapon:DeadEyeRunning() and weapon:GetDEState() == "Shooting" then if tg ~= nil and tg ~= NULL then local ang_1 = ((weapon:GetTargetPos(tg) - h_bp)):Angle() vm:ManipulateBoneAngles(h_b, ang_1) else vm:ManipulateBoneAngles(h_b, a_zero) end else vm:ManipulateBoneAngles(h_b, a_zero) end end hook.Add("UpdateAnimation", "DeadEye_DirectArm", DeadEye_DirectArm) Thanks in advance for any response.
Try this: local ang_1 = ((weapon:GetTargetPos(tg) - h_bp)):Angle() pos_1 = h_bp -- just need something for WorldToLocal to work pos_1, ang_1 = WorldToLocal(pos_1, ang_1, h_bp, h_ba) vm:ManipulateBoneAngles(h_b, ang_1)
First for answering :] With your suggestion: https://files.facepunch.com/forum/upload/185744/22d7c3e6-437a-4dff-bf24-aaff26e3073d/newde.mp4
Sorry, you need to Log In to post a reply to this thread.