Greenie0101 Posted July 30, 2012 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. New CMG 2.0 Screenshot! http://img560.imageshack.us/img560/4269/cmg2screen.png CMG 2.0 Trailer! Learn to script from simple video tutorials completely free! Click here for forum page Was the scripter for CMG server! Leaving CMG: 100%
Anderl Posted July 30, 2012 Posted July 30, 2012 https://wiki.multitheftauto.com/wiki/SetPedControlState https://wiki.multitheftauto.com/wiki/SetElementRotation ? "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Greenie0101 Posted July 30, 2012 Author 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? New CMG 2.0 Screenshot! http://img560.imageshack.us/img560/4269/cmg2screen.png CMG 2.0 Trailer! Learn to script from simple video tutorials completely free! Click here for forum page Was the scripter for CMG server! Leaving CMG: 100%
50p Posted July 30, 2012 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
Greenie0101 Posted August 25, 2012 Author 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 New CMG 2.0 Screenshot! http://img560.imageshack.us/img560/4269/cmg2screen.png CMG 2.0 Trailer! Learn to script from simple video tutorials completely free! Click here for forum page Was the scripter for CMG server! Leaving CMG: 100%
Tails Posted September 18, 2014 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. Discord: its.tails
undefined Posted September 18, 2014 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?
-.Paradox.- Posted September 18, 2014 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 If you're looking for a cheap paid scripter, don't hesitate to contact me. Great minds discuss ideas, Average minds discuss events and small minds discuss people.
arezu Posted September 19, 2014 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).
Tails Posted September 19, 2014 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 Discord: its.tails
Drakath Posted January 3, 2016 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
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