DarkLink Posted June 17, 2012 Share Posted June 17, 2012 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 I tryed to change camera with "V" key and nothing ... Thanks alot in advance guys ! Link to comment
DiSaMe Posted June 17, 2012 Share Posted June 17, 2012 I think that's because it has collision which camera cannot go though. Try disabling the collision of object: setElementCollisionsEnabled Link to comment
ahdon Posted June 17, 2012 Share Posted June 17, 2012 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 Link to comment
DarkLink Posted June 17, 2012 Author Share Posted June 17, 2012 Thanks alot mate, u seem like a boss Problem solved ! Link to comment
50p Posted June 18, 2012 Share Posted June 18, 2012 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. Link to comment
DNL291 Posted June 18, 2012 Share Posted June 18, 2012 You want attach an object on the back of player? if yes just use the function attachElements() Link to comment
DarkLink Posted June 18, 2012 Author Share Posted June 18, 2012 Okay thanks alot mate, got it fixed Link to comment
DiSaMe Posted June 18, 2012 Share Posted June 18, 2012 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. 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