Jump to content

Blow vehicle towards a point


Deltanic

Recommended Posts

i had somewhere a function to count angle between points, and i have a function to get an angle (comparing to Y axis) of element velocity - which you will have to "inverse" in some way. then you will be able to count it.

let me search for them

make a function from this, and return angle

viewtopic.php?f=91&t=29586&p=324244&hilit=north#p324244

and a function to get angle of velocity:

  
function getElementVelocityAngle(vehicle) 
    if (isElement(vehicle)) then 
        local vx,vy,vz = getElementVelocity(vehicle) 
        local cosX2 = (math.deg(math.atan(vx/vy))+90) 
        if (vy>0) then cosX2=cosX2+180 end 
        cosX2 = 360-cosX2 
        cosX2 = cosX2+270 
        if (cosX2 > 360) then cosX2 = cosX2-360 end 
        return cosX2 
    end 
end 
  

idk how to reverse it :P

Link to comment
function blowElement(element,x,y,z,speed) 
    local ex,ey,ez = getElementPosition(element) 
    x,y,z = x-ex,y-ey,z-ez 
    local dist = math.sqrt(x*x+y*y+z*z) 
    x = x*speed/dist 
    y = y*speed/dist 
    z = z*speed/dist 
    setElementVelocity(element,x,y,z) 
end 

Didn't test, but it should work.

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