Sasu Posted February 23, 2015 Share Posted February 23, 2015 Hi all! I'm trying to do a shooter script but I have a problem with the projectile direction: function ejectProjectile() local localVehicle = getPedOccupiedVehicle(source) local ax, ay, az = getElementPosition(source) local x,y,z = getPositionFromElementOffset(localVehicle,0,5,0) local _, _, rz = getElementRotation(localVehicle) local vx, vy = x - ax, y - ay createProjectile(source, 19, x, y, z, 100, nil, 0, 0, 180 - rz, vx/3, vy/3, 0) -- I take velocity math here: viewtopic.php?p=357503#p357503 end The problem is that the projectile goes right(red arrow) and not straight(blue arrow) where it should go. I'm not good in math so if anybody can help me I will be very grateful . Thank you very much. Link to comment
arezu Posted February 23, 2015 Share Posted February 23, 2015 (edited) You can just do this and it will automatically shoot forwards, and it wont collide with your vehicle either. function ejectProjectile() local vehicle = getPedOccupiedVehicle(source) if(vehicle)then local x, y, z = getElementPosition(vehicle) createProjectile(vehicle, 19, x, y, z) end end I edited the wiki page for createProjectile for others that need it as well. Edited February 23, 2015 by Guest Link to comment
Sasu Posted February 23, 2015 Author Share Posted February 23, 2015 Lol, I didn't know that. haha. Thank you very much. Link to comment
Sasu Posted February 25, 2015 Author Share Posted February 25, 2015 Another question, are the projectiles synced with the clients? Or I have to trigger server and then client? Link to comment
Bonsai Posted February 25, 2015 Share Posted February 25, 2015 More or less synced, but you don't need to do any additional stuff. 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