AlvarO Posted April 4, 2015 Share Posted April 4, 2015 Hello guys, yesterday i was creating a script, a car who launch rockets, but i got a question... How can I put for that when you launch a rocket (for example a grenade) it goes for where you are looking with the screen? I dont know if I explained good because my english is a pretty shit. There you have the code: function shootProjectile() local vehicle = getPedOccupiedVehicle(localPlayer) if(vehicle)then local x, y, z = getElementPosition(vehicle) createProjectile(vehicle, 19, x, y, z) else outputChatBox("No estas dentro de un vehiculo",255, 0, 0) end end bindKey("k", "down", shootProjectile) Link to comment
Enargy, Posted April 5, 2015 Share Posted April 5, 2015 try local x, y, z = getElementPosition(localPlayer) instead of local x, y, z = getElementPosition(vehicle) Link to comment
AlvarO Posted April 5, 2015 Author Share Posted April 5, 2015 Is the same, make the same function but what I want is launch the rocket where the camera is looking. I don't know but I think I've to use: setCameraMatrix Link to comment
Mr.unpredictable. Posted April 5, 2015 Share Posted April 5, 2015 You want to aim where your car is facing? Link to comment
AlvarO Posted April 5, 2015 Author Share Posted April 5, 2015 No, see, I want the missile looking out to where the screen, for example the car is looking at a building and I'm looking to the right, so I want that the missile will be launched to the right. Link to comment
novo Posted April 5, 2015 Share Posted April 5, 2015 I guess you will then have to use getCameraMatrix and its facing integers together with few arithmetic operations. Link to comment
AlvarO Posted April 5, 2015 Author Share Posted April 5, 2015 Then how it will looks like? The script I mean Link to comment
Mr.unpredictable. Posted April 6, 2015 Share Posted April 6, 2015 use these functions getCameraMatrix getElementPosition getElementMatrix getElementRotation 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