Jump to content

Ped Rotation


Recommended Posts

Posted

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) 

Posted
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.

Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...