kieran Posted November 28, 2017 Share Posted November 28, 2017 Hey, so I know how to make a 3D image in the GTA world, but I want to animate it to turn like a gif, I don't know any way of doing this though... Is there any suggestions/solutions to how I can move it when the client renders? Here is code to create the image size = 3 local img = dxCreateTexture("circle.png") --The image function createIMG() -- x,y,z, targetx,targety,targetz,texture,width,color,lookx,looky,lookz x,y,z = -2329.3, -1605.6, 483.2 --Coordinates image = dxDrawMaterialLine3D (x, y, z, x+size, y, z+size/2,img, size, tocolor(255,255,255,255), x, y+10, z) --draw the image --How would I rotate the image? end addEventHandler("onClientRender", root, createIMG) The only way I could think of is making the image an element somehow and then rotating it... But I don't know how I'd do that, thanks for any advice/help. Link to comment
Mr.Loki Posted November 29, 2017 Share Posted November 29, 2017 For it to rotate you need to use the lookAt args and and use sine and cosine to rotate around the x and y. Also the way u calculated the size made the image oval and i fixed that. local size = 3 local img = point(500,-1) local rot = 0 function createIMG() local x,y,z = local rx = math.sin(rot)*1 local ry = math.cos(rot)*1 dxDrawMaterialLine3D( x, y, z, x, y, z+size, img, size, -1, x+rx, y+ry, z ) rot = rot +.01 end addEventHandler("onClientRender", root, createIMG) Link to comment
kieran Posted November 29, 2017 Author Share Posted November 29, 2017 @Mr.Loki Thanks, but I want it to rotate clockwise, not spin on the z axis... Link to comment
Mr.Loki Posted November 29, 2017 Share Posted November 29, 2017 1 hour ago, kieran said: @Mr.Loki Thanks, but I want it to rotate clockwise, not spin on the z axis... Try this local size = 1 local img = point(100,-1) local rot = 0 function createIMG(dt) local x,y,z = getElementPosition( localPlayer ) local rx = math.sin(rot)*size local rz = math.cos(rot)*size dxDrawMaterialLine3D( x-rx, y, 1+z-rz, x+rx, y, 1+z+rz, img, size*2, -1, x, y+1, 1+z ) rot = rot +(.01*dt/17) end addEventHandler("onClientPreRender", root, createIMG) Link to comment
kieran Posted November 29, 2017 Author Share Posted November 29, 2017 Thanks @Mr.Loki, one question though... why do you pass dt? Link to comment
Moderators IIYAMA Posted November 30, 2017 Moderators Share Posted November 30, 2017 https://wiki.multitheftauto.com/wiki/OnClientPreRender dt is the timeslice. Read the wiki. It is the delay/time between the frames, created ONLY by the onClientPreRender If you have 60 fps. The timeslice is around: 1000(1sec) / 60 = 16,666666666666667 ms. 1 Link to comment
Slim Posted December 1, 2017 Share Posted December 1, 2017 https://community.multitheftauto.com/?p=resources&s=details&id=12052 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