Jump to content

Pickups


Recommended Posts

I know what you do mean, you must look at race's client code and check how the pickups work. You can start by looking at the code following to the line nº1352 ("Make vehicle upright") at the race_client.lua file; which must be like the following:

  
------------------------ 
-- Make vehicle upright 
  
function directionToRotation2D( x, y ) 
    return rem( math.atan2( y, x ) * (360/6.28) - 90, 360 ) 
end 
  
function alignVehicleWithUp() 
    local vehicle = g_Vehicle 
    if not vehicle then return end 
  
    local matrix = getElementMatrix( vehicle ) 
    local Right = Vector3D:new( matrix[1][1], matrix[1][2], matrix[1][3] ) 
    local Fwd   = Vector3D:new( matrix[2][1], matrix[2][2], matrix[2][3] ) 
    local Up    = Vector3D:new( matrix[3][1], matrix[3][2], matrix[3][3] ) 
  
    local Velocity = Vector3D:new( getElementVelocity( vehicle ) ) 
    local rz 
  
    if Velocity:Length() > 0.05 and Up.z < 0.001 then 
        -- If velocity is valid, and we are upside down, use it to determine rotation 
        rz = directionToRotation2D( Velocity.x, Velocity.y ) 
    else 
        -- Otherwise use facing direction to determine rotation 
        rz = directionToRotation2D( Fwd.x, Fwd.y ) 
    end 
  
    setElementRotation( vehicle, 0, 0, rz ) 
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...