lolek123 Posted March 18, 2013 Share Posted March 18, 2013 Yo, I replaced a ped with a much bigger one. A dinosaur Now I want to set him an animation. I'm trying to make him walk. My problem is that he takes big steps, but it seems like he's not moving at all. Is there any way that I could speed him up, so I will synchronize the animation with his actual steps? Thanks. Link to comment
MIKI785 Posted March 18, 2013 Share Posted March 18, 2013 setElementPosition will do it, you can put it in onClientRender to make it smooth. I don't think there's any other way to speed it up. Link to comment
lolek123 Posted March 19, 2013 Author Share Posted March 19, 2013 addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() txd = engineLoadTXD ( "data/Velociraptor/velociraptor.txd" ) engineImportTXD ( txd, 1 ) dff = engineLoadDFF ( "data/Velociraptor/velociraptor.dff" ) engineReplaceModel ( dff, 1 ) txd2 = engineLoadTXD ( "data/Tyrannosaurus/tyrannosaurus.txd" ) engineImportTXD ( txd2, 2 ) dff2 = engineLoadDFF ( "data/Tyrannosaurus/tyrannosaurus.dff" ) engineReplaceModel ( dff2, 2 ) end) addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), function() ped1 = createPed ( 1, 2471, -1655, 14, 90 ) ped2 = createPed ( 2, 2471, -1658, 14, 90 ) ped3 = createPed ( 1, 2471, -1661, 14, 90 ) ped4 = createPed ( 1, 2471, -1664, 14, 90 ) ped5 = createPed ( 1, 2471, -1667, 14, 90 ) setPedAnimation( ped1, "FAT", "FatSprint") setPedAnimation( ped2, "FAT", "FatWalk", 0, true, true ) end) addEventHandler( "onClientRender", , smooth ) function smooth () root = getRootElement() local x, y, z = getElementPosition( ped2 ) setElementPostion( ped2, x + 10, y, z ) end Help would be appreciated, thank you. Link to comment
PaiN^ Posted March 19, 2013 Share Posted March 19, 2013 Try this : ped1 = createPed ( 1, 2471, -1655, 14, 90 ) ped2 = createPed ( 2, 2471, -1658, 14, 90 ) ped3 = createPed ( 1, 2471, -1661, 14, 90 ) ped4 = createPed ( 1, 2471, -1664, 14, 90 ) ped5 = createPed ( 1, 2471, -1667, 14, 90 ) setPedAnimation( ped1, "FAT", "FatSprint") setPedAnimation( ped2, "FAT", "FatWalk", 0, true, true ) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() txd = engineLoadTXD ( "data/Velociraptor/velociraptor.txd" ) engineImportTXD ( txd, 1 ) dff = engineLoadDFF ( "data/Velociraptor/velociraptor.dff" ) engineReplaceModel ( dff, 1 ) txd2 = engineLoadTXD ( "data/Tyrannosaurus/tyrannosaurus.txd" ) engineImportTXD ( txd2, 2 ) dff2 = engineLoadDFF ( "data/Tyrannosaurus/tyrannosaurus.dff" ) engineReplaceModel ( dff2, 2 ) end ) addEventHandler( "onClientRender", root, function ( ) local x, y, z = getElementPosition ( ped2 ) setElementPosition ( ped2, x + 10, y, z ) end ) Link to comment
DiSaMe Posted March 19, 2013 Share Posted March 19, 2013 Using setElementPosition without setting the 5th argument to false will reset the animation. Try something like this for speed-up: local speedmult = 0.1 addEventHandler("onClientPreRender", root, function(timeslice) local x, y, z = getElementPosition(ped2) local vx, vy, vz = getElementVelocity(ped2) local speedmult = speedmult*timeslice vx, vy, vz = vx*speedmult, vy*speedmult, vz*speedmult setElementPosition(ped2, x+vx, y+vy, z+vz, true) end ) As you can see, it gets the velocity of the ped, multiplies it by some value (you can change the speed by editing the speedmult value) and adds it to the position, so it moves in the direction where the animations and control states make it move. Link to comment
lolek123 Posted March 19, 2013 Author Share Posted March 19, 2013 Hell yea, man! Awesome. I'd never get it myself. Really pleased there are people that are willing to help. 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