McDeKi Posted September 24, 2014 Share Posted September 24, 2014 Hey, I've noticed that when the player is aiming the rotation of objects attached with bone_attach ( latest one ) is delayed. aiming: the rotation/postion is delayed normal rotation: everything works fine local r = 0 function s2() if r >= 360 then r = 0 end r = r + 20 setPedCameraRotation( localPlayer, -r ) end local w = false function s() w = not w if w then addEventHandler('onClientRender', root, s2) else removeEventHandler('onClientRender', root, s2) end end addCommandHandler("ro", s) function s3() if r >= 360 then r = 0 end r = r + 20 x,y = getElementRotation(localPlayer) setElementRotation( localPlayer, x, y, r) end local wr = false function s4() wr = not wr if wr then addEventHandler('onClientRender', root, s3) else removeEventHandler('onClientRender', root, s3) end end addCommandHandler('po', s4) I've used this code for testing. I've tried: -setting player rotation to object rotation - didnt work -attachElements ( the rotation and postion still were delayed ) -getting postion of muzzle ( getPedWeaponMuzzlePosition ) and passing it instead of getPedBonePosition - didnt work -setCameraTarget ( the rotation still was delayed ) -setPedCameraRotation ( the rotation still was delayed ) -setCameraTarget + setCameraMatrix - didnt work very well, still was delayed I think the problem is setElementRotation / setElementPosition Its very big problem for me, cus I wanted to make a custom clothes for peds and the flashlight for weapons, but as you can see the rotation goes weird when the camera is being moved. Any help will be greatly appreciated Edit: Also I've tried SAMP's bone attach and everything worked fine :C Link to comment
eAi Posted September 25, 2014 Share Posted September 25, 2014 Try using onClientPreRender rather than onClientRender. By using onClientRender, you're taking the position of the bone just after it has been rendered, then setting the position of the attached object in the next frame, so you always see your attached object where the bone was the previous frame. Your variable and function names are atrocious. Link to comment
McDeKi Posted September 25, 2014 Author Share Posted September 25, 2014 Bone_attach is already onClientPreRender( I've changed it to onClientRender, but it didnt change anything). Link to comment
Rilot Posted July 15, 2020 Share Posted July 15, 2020 @McDeKi Hi! I was wondering if could you fix it. If you did, how? I have the same problem, I use bone attach for taser but when I aim, it's really delayed. Thank you! Link to comment
Scripting Moderators ds1-e Posted July 15, 2020 Scripting Moderators Share Posted July 15, 2020 1 hour ago, Rilot said: @McDeKi Hi! I was wondering if could you fix it. If you did, how? I have the same problem, I use bone attach for taser but when I aim, it's really delayed. Thank you! This topic is from 2014. I doubt that he would answer you. Did you tried to make attachment on client-side? If you create object at server-side then no wonder why it's delayed. Link to comment
Rilot Posted July 16, 2020 Share Posted July 16, 2020 22 hours ago, majqq said: This topic is from 2014. I doubt that he would answer you. Did you tried to make attachment on client-side? If you create object at server-side then no wonder why it's delayed. Ikr, it's old as hell. I didn't tried, if I'm correct, if I try it on client side, it's only gonna be showed for localPlayer. Or maybe I could do it with triggering server event or something, but that would give it delay too. Link to comment
Scripting Moderators ds1-e Posted July 16, 2020 Scripting Moderators Share Posted July 16, 2020 13 minutes ago, Rilot said: Ikr, it's old as hell. I didn't tried, if I'm correct, if I try it on client side, it's only gonna be showed for localPlayer. Or maybe I could do it with triggering server event or something, but that would give it delay too. Attach with trigger, it will be shown for all players, but do not forget to create object directly on client-side. Delay before attached object will appear wouldn't be significant. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now