AlvarO Posted April 4, 2015 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)
Enargy, Posted April 5, 2015 Posted April 5, 2015 try local x, y, z = getElementPosition(localPlayer) instead of local x, y, z = getElementPosition(vehicle)
AlvarO Posted April 5, 2015 Author 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
Mr.unpredictable. Posted April 5, 2015 Posted April 5, 2015 You want to aim where your car is facing?
AlvarO Posted April 5, 2015 Author 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.
novo Posted April 5, 2015 Posted April 5, 2015 I guess you will then have to use getCameraMatrix and its facing integers together with few arithmetic operations.
AlvarO Posted April 5, 2015 Author Posted April 5, 2015 Then how it will looks like? The script I mean
Mr.unpredictable. Posted April 6, 2015 Posted April 6, 2015 use these functions getCameraMatrix getElementPosition getElementMatrix getElementRotation
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