FlyingSpoon Posted June 26, 2016 Posted June 26, 2016 Hey I want to make the ped rotate, while choosing skins. So for example I made a skin selector, but I want to rotate the ped 360, smoothly while the player browses through the skins, how would I do this? function spawnMenu() setCameraMatrix ( 1950.25879, -1771.79895, 13.44688, 1700.25879, -1759.79895, 13.54688 ) spawnPed = createPed ( 29, 1947.74756, -1771.68896, 13.54688, 265 ) setElementFrozen ( spawnPed, true ) leftBtn = guiCreateButton(0.04, 0.44, 0.03, 0.04, "<", true) rightBtn = guiCreateButton(0.28, 0.44, 0.03, 0.04, ">", true) spawnBtn = guiCreateButton(0.075, 0.44, 0.20, 0.04, "Spawn", true) addEventHandler("onClientRender", getRootElement(), textRect) showCursor ( true ) end addEvent("spawnMenu:chooseCharacter", true) addEventHandler("spawnMenu:chooseCharacter", root, spawnMenu) GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
xXMADEXx Posted June 26, 2016 Posted June 26, 2016 You can see how I did it here: https://github.com/braydondavis/Nerd-Ga ... hicles.lua Use onClientPreRender instead, it will make it smoother. The Ultimate Lua Tutorial! | MTA PHP SDK
#RooTs Posted June 26, 2016 Posted June 26, 2016 You can see how I did it here: https://github.com/braydondavis/Nerd-Ga ... hicles.luaUse onClientPreRender instead, it will make it smoother. where the argument rotation? tempPed = createPed ( getElementModel ( localPlayer ), 0, 0, 0 );
FlyingSpoon Posted June 26, 2016 Author Posted June 26, 2016 function spawnMenu() setCameraMatrix ( 1950.25879, -1771.79895, 13.44688, 1700.25879, -1759.79895, 13.54688 ) spawnPed = createPed ( 29, 1947.74756, -1771.68896, 13.54688, 265 ) setElementFrozen ( spawnPed, true ) leftBtn = guiCreateButton(0.04, 0.44, 0.03, 0.04, "<", true) rightBtn = guiCreateButton(0.28, 0.44, 0.03, 0.04, ">", true) spawnBtn = guiCreateButton(0.075, 0.44, 0.20, 0.04, "Spawn", true) addEventHandler("onClientRender", getRootElement(), textRect) showCursor ( true ) addEventHandler ( "onClientRender", root, onRender ); end addEventHandler("onClientResourceStart", root, spawnMenu) function onRender ( ) if ( isElement( spawnPed ) ) then local _, _, rz = getElementRotation ( spawnPed ); local rz = rz - 1; if ( rz <= 1 ) then rz = 359; end setElementRotation ( spawnPed, 0, 0, rz ); end end I want it to go smooth and slow, but it's just going really fast and looks like it's glitching. GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
Walid Posted June 26, 2016 Posted June 26, 2016 rotate the camera around the ped i think it's much better try it: local facing = 0 function rotateCameraAroundPed( ) if spawnPed and isElement(spawnPed) then local x, y, z = getElementPosition(spawnPed) local camX = x + math.cos( facing / math.pi * 180 ) * 5 local camY = y + math.sin( facing / math.pi * 180 ) * 5 setCameraMatrix( camX, camY, z+1, x, y, z ) facing = facing + 0.00009 end end -- start rotateCameraAroundPed() function addEventHandler( "onClientRender", getResourceRootElement( ), rotateCameraAroundPed ) -- stop rotateCameraAroundPed() function removeEventHandler( "onClientRender", getResourceRootElement( ), rotateCameraAroundPed ) Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
FlyingSpoon Posted June 26, 2016 Author Posted June 26, 2016 Fixed thanks Works like charm. But I was really looking for the other type of function, this will do for the time being, thanks Walid GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
Walid Posted June 26, 2016 Posted June 26, 2016 You are welcome. Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
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