Jump to content

Package always on back


DarkLink

Recommended Posts

Posted

Hi there guys, I read something by 50p on another post on how to do this.. and from what I understood on that day, I would need to use onClientPreRender, and setElementPosition and setElementRotation on the handler function of the event...

So I made this:

  
  
local object 
function pickweed() 
    local x,y,z = getElementPosition(getLocalPlayer()) 
    local xr,yr,zr = getElementRotation(getLocalPlayer()) 
    object = createObject (1578, x,y-0.0999755859,z+0.300000191) 
    setElementRotation(object, xr, yr+82, zr+270) 
     
    addEventHandler ( "onClientPreRender", getRootElement(), updateObjectCoords) 
end 
addCommandHandler ("pick", pickweed ) 
  
function updateObjectCoords() 
    local x,y,z = getElementPosition(getLocalPlayer()) 
    local xr,yr,zr = getElementRotation(getLocalPlayer()) 
    setElementPosition(object, x,y-0.0999755859,z+0.300000191) 
    setElementRotation(object, xr, yr+82, zr+270) 
     
end 
  

And I guess its fine, but the camera changes gets ZOOMED alot... I dont know why :S

I tryed to change camera with "V" key and nothing ...

Thanks alot in advance guys !

Posted

I think that's because it has collision which camera cannot go though. Try disabling the collision of object:

setElementCollisionsEnabled 

Posted
function pickweed() 
    local x,y,z = getElementPosition(localPlayer) 
    local xr,yr,zr = getElementRotation(localPlayer) 
    object = createObject (1578, x,y-0.0999755859,z+0.300000191) 
    setElementRotation(object, xr, yr+82, zr+270) 
    addEventHandler("onClientPreRender",root,updateObjectCoords) 
end 
addCommandHandler ("pick", pickweed ) 
  
function updateObjectCoords() 
    local x,y,z = getElementPosition(localPlayer) 
    local xr,yr,zr = getElementRotation(localPlayer) 
    setElementPosition(object, x,y-0.0999755859,z+0.300000191) 
    setElementRotation(object, xr, yr+82, zr+270) 
    setElementCollisionsEnabled(object, false) 
end 
  

Posted
function pickweed() 
    local x,y,z = getElementPosition(localPlayer) 
    local xr,yr,zr = getElementRotation(localPlayer) 
    object = createObject (1578, x,y-0.0999755859,z+0.300000191) 
    setElementRotation(object, xr, yr+82, zr+270) 
    addEventHandler("onClientPreRender",root,updateObjectCoords) 
end 
addCommandHandler ("pick", pickweed ) 
  
function updateObjectCoords() 
    local x,y,z = getElementPosition(localPlayer) 
    local xr,yr,zr = getElementRotation(localPlayer) 
    setElementPosition(object, x,y-0.0999755859,z+0.300000191) 
    setElementRotation(object, xr, yr+82, zr+270) 
    setElementCollisionsEnabled(object, false) 
end 
  

You don't have to do it on every frame. Just disable collision after creating the object.

Posted

Or even better, attach it using bone attachments resource from here or here and it will move and rotate with the body part which it is attached to.

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