Vehicle angle wrong

Started by Ankris, Nov 25, 2016, 08:21 PM

Previous topic - Next topic

Ankris

No matter what I do (Euler & Quaternion), I always get the same angle:



when I want this angle:



Any idea?

Mötley

Have you tried

http://forum.liberty-unleashed.co.uk/index.php/topic,1771.0.html ?

This is a bug that really needs to be solved..

I hope you didn't do a lot of vehicle saving at once >:( :-[..

Ankris

Quote from: Mötley on Nov 26, 2016, 12:03 AMHave you tried

http://forum.liberty-unleashed.co.uk/index.php/topic,1771.0.html ?

This is a bug that really needs to be solved..

I hope you didn't do a lot of vehicle saving at once >:( :-[..

10 vehicles. And yes, I already tried this and same result.

Mötley

#3
I will figure something out, Unless someone better than me finds out a better method.

But for now.. I had used player.Angle in the past.. But you need to drive straight to where you want the car, From what I remember, No direct car spawn, enter, turn save, etc..

Something like this should buy you some time until someone else helps,.. :-\

  if (cmd == "angle")
  {
        if (player.Vehicle)
        {
             print("Broken Angle " + player.Vehicle.Angle)
             player.Vehicle.Angle = player.Angle;
             print("New Angle " + player.Vehicle.Angle)
             /* In-case something weird happened */
             print("The new angle should return " + player.Angle)
        }
        else MessagePlayer("Wheres the car?", player, 255, 0, 0);
  }

Maybe you could try setting the players angle instead to what you want it. If the vehicle angles to your desire save it with player.Angle. Should do the trick

Xmair

function GetRadiansAngle(Rotation)
{
 local angle;
 angle = ::asin( Rotation.z ) * -2;
 return Rotation.w < 0 ? 3.14159 - angle : 6.28319 - angle;
}
Source.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Ankris

Quote from: Mötley on Nov 26, 2016, 12:14 AM...

This crashes

Quote from: Xmair on Nov 26, 2016, 04:52 AMfunction GetRadiansAngle(Rotation)
{
 local angle;
 angle = ::asin( Rotation.z ) * -2;
 return Rotation.w < 0 ? 3.14159 - angle : 6.28319 - angle;
}
Source.

Still being the same.



Here's my code:

/setangle:
db.query("UPDATE vehicles SET rx="+player.Vehicle.EulerAngle.x+", ry="+player.Vehicle.EulerAngle.y+", rz="+GetRadiansAngle(player.Vehicle.Angle)+" WHERE id="+player.Vehicle.ID);

Message("Angle set to: "+player.Vehicle.EulerAngle);
Message("AngleZ radians: "+GetRadiansAngle(player.Vehicle.Angle));

LoadVehicles:
local rot = Vector(sqlite_column_data(query, 4), sqlite_column_data(query, 5), sqlite_column_data(query, 6));
vehicle.EulerAngle = rot;

Xmair

Just use the function instead of rotation angle x,y,z.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Mötley

local rot = Vector(sqlite_column_data(query, 4), sqlite_column_data(query, 5), sqlite_column_data(query, 6));
vehicle.EulerAngle = rot;

What?!



My code does not crash for me. I have been able to save vehicle angles.

For me, I just set the vehicle angle to be the players angle, Set the angle to my desire, Then save that vehicle,

I just use Vehicle.Angle when installing the cars.

Player.Angle for saving the car.

Not some Vector. But maybe there is supposed to be a different way idk..

KAKAN

Ankris, use like this:-
"Update h set angle="+player.Vehicle.GetRadiansAngle()
Then, use that angle instead of vector while creating the vehicle
oh no

Ankris

OK I got it, vehicles starts from 1 instead of 0 and I was saving the wrong car.

Thank you to everyone who tried to help me c: