DakiLLa Posted April 10, 2009 Share Posted April 10, 2009 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: 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
Gamesnert Posted April 10, 2009 Share Posted April 10, 2009 Try: math.abs(rvz) Because vrz is probably a negative value, math.abs should make it positive. Just a wild guess, might work though. Link to comment
darkdreamingdan Posted April 10, 2009 Share Posted April 10, 2009 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
DakiLLa Posted April 11, 2009 Author Share Posted April 11, 2009 yea, the math.abs works perfect, and %360 multiplying points in geometry progression..wtf is this? anyway, thx for help Link to comment
50p Posted April 11, 2009 Share Posted April 11, 2009 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
DakiLLa Posted April 11, 2009 Author Share Posted April 11, 2009 eh..and what are these problems? i see that all going good when i'm driving.. btw thx for your script...it's rly better than mine.. Link to comment
50p Posted April 12, 2009 Share Posted April 12, 2009 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now