Jump to content

projectile path depending on turret


John Smith

Recommended Posts

hello there

i was messing around with projectile function(createProjectile) and it was fun yeah but i don't really know how to change projectile's path

to be more clear this is what i want to do

- i get in let's say s.w.a.t. vehicle because it has a turret

- i click a key and it fires a rocket depending on turret rotation and position

i know how to make a projectile, bind a key and that stuff but i don't know how to do the following

1) create that projectile exactly on (getVehicleTurretPosition) which doesn't have a z value?

2) set projectile's rotation exactly to follow the direction of turret(if pointed to air, it would go in that direction;air)

3) make that projectile really fast without it actually changing original direction

i have ended up with just projectiles going all around who knows where, they seem also to be like flies(just go and circle around for no reason)

if anyone can help me with those projectile directions,rotations i would appreciate it,thanks.

Link to comment
  • 1 month later...

i still am not sure how to predict where a projectile will be shot at

with regular weapons and creating projectiles onto them its easy because of the functions getPedTargetStart and getPedTargetEnd

can this (creating projectiles from turret towards point that turret is facing) be done with getting camera matrix or something?

i just want to increase the distance where rhino can shoot at

edit: maybe with useful function getPositionFromElementOffset?

--

function getPositionFromElementOffset(element,offX,offY,offZ) 
    local m = getElementMatrix ( element )  -- Get the matrix 
    local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] 
    local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] 
    local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] 
    return x, y, z 
end 

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...