JeViCo Posted August 26, 2018 Share Posted August 26, 2018 Hello everyone! i use this code to change player's rotation: function updateCamera() x,y,z,tx,ty,tz = getCameraMatrix() newangle = (( 360 - math.deg ( math.atan2 ( ( x - tx ), ( y - ty ) ) ) ) % 360)-180 setElementRotation( localPlayer,0,0, -newangle ) end addEventHandler ( "onClientPreRender", getRootElement(), updateCamera ) also i use bone_attach resource to attach the object to a player. When a player rotates - object rotates too but in opposite direction and i don't know why. How can i fix it? Link to comment
SycroX Posted August 26, 2018 Share Posted August 26, 2018 23 minutes ago, JeViCo said: Hello everyone! i use this code to change player's rotation: function updateCamera() x,y,z,tx,ty,tz = getCameraMatrix() newangle = (( 360 - math.deg ( math.atan2 ( ( x - tx ), ( y - ty ) ) ) ) % 360)-180 setElementRotation( localPlayer,0,0, -newangle ) end addEventHandler ( "onClientPreRender", getRootElement(), updateCamera ) also i use bone_attach resource to attach the object to a player. When a player rotates - object rotates too but in opposite direction and i don't know why. How can i fix it? use setElementAttachedOffsets / getElementAttachedOffsets Link to comment
Discord Moderators Pirulax Posted August 26, 2018 Discord Moderators Share Posted August 26, 2018 Do a 360-newangle Link to comment
JeViCo Posted August 26, 2018 Author Share Posted August 26, 2018 solved. I added my function at the end of bone_attach function (pre-render event). Bone_attach had loop so it didn't keep up after rotation function. Thanks anyway for suggestions 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