Jump to content

problem with angle's


DakiLLa

Recommended Posts

hi. i'm writing simple drift system, but i have one problem..

Well, the way that i'm going:

check player vehicle speed and angle of rotation of vehicle. The problem is:

- I have set the min and max angle speed for vehicle after which it can call counting of points.

minspeed = 0.4 
maxspeed = 1.5 
minturnspeed = math.rad(1) 
maxturnspeed = math.rad(45) 

- I can call counting of points ONLY when i'm driving in left way (turning the wheels to the left).

function driftProcess() 
    local vehicle = getPlayerOccupiedVehicle( gMe ) 
    if vehicle then 
         
        local vx, vy, vz = getElementVelocity(vehicle) 
        local rx, ry, rz = getVehicleRotation(vehicle) 
        local rvx, rvy, rvz = getVehicleTurnVelocity(vehicle) 
         
        local speed = math.sqrt(vx*vx + vy*vy + vz*vz) 
         
        local onGround = isVehicleOnGround(vehicle) -- this wont work for monster truck 
        local upright =((rx >= 0 and rx <= 90) or (rx >= 270 and rx <= 360)) and ((ry >= 0 and ry <= 90) or (ry >= 270 and ry <= 360)) 
        if onGround == true and upright == true then 
            if speed >= minspeed and rvz >= minturnspeed then 
            -- counting operators... 
  

..but when i do check on negative angle, i can get points when i'm driving in direct way..

I'm bad with trigonometry, but i think that it looks like that:

36a9c65a2c99.png

So i need to set that the vehicle can steer right and get points after that..but how?

Thanks for any replies. :)

May be the video will explain what i mean in more understandable form...

*When i'm driving the left - i'm getting points (look on the chat). When the right - nothing*

Link to comment
Try:
math.abs(rvz) 

Because vrz is probably a negative value, math.abs should make it positive. Just a wild guess, might work though.

As far as angles go, i wouldnt use math.abs but the modulo operator instead, i.e.

rvz = rvz%360

That will take into account any values outside of the 0-360 range.

Link to comment

Drifting script was one of my first scripts for MTA (it was being developed looong time ago) but I never finished it. So, maybe you'll want to take a look and finish it. There were some problems with angles when drifting from NorthEast -> North and NorthWest -> North.

Link to comment

I can't remember very well because it was long time ago since I stopped scripting it... I think the problem was with angles when max and min angles change while drifting NE -> N and NW -> N. Test it on an airport.. I can't really remember and can't test it myself due to lack of time, sorry. I hope you'll make some nice script with it.

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