Jump to content

Projectiles detouring


12p

Recommended Posts

Ok guys look, I've got this code:

  
    local findX, findY, findZ = getWorldFromScreenPosition(cx, cy, 60) 
    local rlX, rlY, rlZ = getElementPosition(localVehicle) 
    rlZ = rlZ+4 
  
    local hit, finalX, finalY, finalZ, element = processLineOfSight(rlX, rlY, rlZ, findX, findY, findZ, true, true, true, true, false, true, true, true, localVehicle, false) 
    if not hit then finalX, finalY, finalZ = findX, findY, findZ end 
     
    if element == nil or getElementType(element) ~= "player" then 
        createProjectile(localPlayer, 19, rlX, rlY, rlZ, 0, nil, findRotation(rlY, rlZ, findY, findZ), findRotation(rlX, rlZ, findX, findZ), findRotation(rlX, rlY, findX, findY), (findX-rlX)/60, (findY-rlY)/60, (findZ-rlZ)/60) 
    else createProjectile(localPlayer, 20, rlX, rlY, rlZ, 1, element) 
    end 

It's supposed to launch a rocket directed to the center of the screen. It works flawlessly if pointing to N or S. Otherwise, it's working, but said rockets detour after some travelled distance, which I believe to be caused by the rotation, but I really can't tell how to fix it... Maybe I'm using findRotation wrong?

I've also tried setting all rotation axis' to 0, but it didn't help.

Can someone help me with this?

It has nothing to do with beforehand values, I've already debugged everything, and the problem is only there in the createProjectile function.

Edited by Guest
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...