Greenie0101 Posted July 30, 2012 Share Posted July 30, 2012 I need help with this! I want to use setElementVelocity to make a ped go forwards (in the direction it is facing). How can I do this as setElementVelocity works along the x and y axis of the map and not the player. Link to comment
Anderl Posted July 30, 2012 Share Posted July 30, 2012 https://wiki.multitheftauto.com/wiki/SetPedControlState https://wiki.multitheftauto.com/wiki/SetElementRotation ? Link to comment
Greenie0101 Posted July 30, 2012 Author Share Posted July 30, 2012 https://wiki.multitheftauto.com/wiki/SetPedControlStatehttps://wiki.multitheftauto.com/wiki/SetElementRotation ? nah dont see how that works, i want it so that if im facing north my velocity will be x, y + 0.1, z. If im facing south it would be x, y - 0.1, z east would be x + 0.1 west x - 0.1 that part is easy but how can i calculate what it should be for all the stuff in between. For example if i face north east (45 degrees) it will be x + 0.1, y +0.1 z. But if im facing at 10 degrees for example, how can i make the script calculate what the x and y should be? Link to comment
50p Posted July 30, 2012 Share Posted July 30, 2012 function setElementForwardVelocity( elem, vel ) local ang = getElementRotation( elem ); ang = math.rad(90 - ang); local vx = math.cos( ang ) * vel; local vy = math.sin( ang ) * vel; return setElementVelocity( elem, vx, vy, 0 ); end Haven't tested it but should work. Link to comment
Greenie0101 Posted August 25, 2012 Author Share Posted August 25, 2012 ok its been a while but i want to come back to this. I want this so that i can put it in the parachute recource so that i glide more than fall. At the moment i did my parachute resource so that if im not holding controls it sets my velocity as x+1 and y+1 but of curse that just has me shooting off 45 degrees NE. How can i set my velocity to make myself go forward as im falling in parachute script Link to comment
Tails Posted September 18, 2014 Share Posted September 18, 2014 function setElementForwardVelocity( elem, vel ) local ang = getElementRotation( elem ); ang = math.rad(90 - ang); local vx = math.cos( ang ) * vel; local vy = math.sin( ang ) * vel; return setElementVelocity( elem, vx, vy, 0 ); end Haven't tested it but should work. Added the function to my script but for e.x: setElementForwardVelocity(localPlayer,2) does nothing for me. Link to comment
undefined Posted September 18, 2014 Share Posted September 18, 2014 function setElementForwardVelocity( elem, vel ) local ang = getElementRotation( elem ); ang = math.rad(90 - ang); local vx = math.cos( ang ) * vel; local vy = math.sin( ang ) * vel; return setElementVelocity( elem, vx, vy, 0 ); end Haven't tested it but should work. What is the math.rad, math.cos and math.sin? Link to comment
-.Paradox.- Posted September 18, 2014 Share Posted September 18, 2014 function setElementForwardVelocity( elem, vel ) local ang = getElementRotation( elem ); ang = math.rad(90 - ang); local vx = math.cos( ang ) * vel; local vy = math.sin( ang ) * vel; return setElementVelocity( elem, vx, vy, 0 ); end Haven't tested it but should work. What is the math.rad, math.cos and math.sin? http://lua-users.org/wiki/MathLibraryTutorial Link to comment
arezu Posted September 19, 2014 Share Posted September 19, 2014 Added the function to my script but for e.x: setElementForwardVelocity(localPlayer,2) does nothing for me. It doesn't work while you stand on the ground, you get stuck. You have to first jump and then use it (alternatively set your position above the ground and then use it, or setElementVelocity upwards and then timer and setElementVelocity forwards, lol). Link to comment
Tails Posted September 19, 2014 Share Posted September 19, 2014 Added the function to my script but for e.x: setElementForwardVelocity(localPlayer,2) does nothing for me. It doesn't work while you stand on the ground, you get stuck. You have to first jump and then use it (alternatively set your position above the ground and then use it, or setElementVelocity upwards and then timer and setElementVelocity forwards, lol). Just shoots me in the same direction every time Link to comment
sNk Posted January 2, 2016 Share Posted January 2, 2016 It just shoots me North... Any Ideas? Link to comment
Drakath Posted January 3, 2016 Share Posted January 3, 2016 math.rad(ang); -East math.rad(90 - ang); -North math.rad(180 - ang); -West math.rad(270 - ang); -South Simple as that. 1 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