[Request] Force player.Angle to update while in vehicle

Started by Mötley, Oct 03, 2018, 03:10 PM

Previous topic - Next topic

Mötley

Player.Angle never updates while in a vehicle. While vehicle.Angle seems broken, it's not broken.
The only part about Vehicle.Angle that's broken is returning vehicle angles, You can set the angle normally based off of player.Angle just fine.

Also Player.Angle returns your last known angle from when you first entered your current vehicle, when you exit a vehicle it returns that angle. But it does start to update around 100 ms after exiting a vehicle, It just returns your last angle for some odd reason, The fact that it never updates while in vehicle is why most users have bugged angles when using player.Angle as a angle for vehicles, it just never updates.

So my request is to force Player.Angle to update while in a vehicle, and not to return the players last know angle when exiting a vehicle. If player.Angle updates it shouldn't do that anyway or at least don't set it for the last known angle, just putting that out there to be sure it get's noted.

I have a snippet from testing, this is for flipping a vehicle back over/sets your vehicles angle to be the same as your current vehicle facing angle.

Leave the timer as is, unless  you want to see how player.Angle returns your last known angle vs your current facing angle.
Hopefully this will help explain what I am talking about as I have the flu and don't feel to well :-[

    if (cmd == "flip") {
      // refresh vehicle
      local vehicle = FindVehicle(player.Vehicle.ID), Vehicle_Model = player.Vehicle.Model, vpos = player.Vehicle.Pos, c1 = player.Vehicle.Colour1, c2 = player.Vehicle.Colour2;
      if (vehicle) {
        // Vehicle fliping around like crazy could possibly cause player.Angle to not update for the given time
        if (vehicle.Speed.x < 0.00005 && vehicle.Speed.y < 0.00005) {
            player.Frozen = true;
            vehicle.Remove();
            // Needs a slight offset as it happens so fast it goes unnoticed
            NewTimer("FlipVehicle", 100, 1, Vehicle_Model, player.ID, vpos.x, vpos.y, vpos.z, c1, c2 );
        }
      }
    }

function FlipVehicle( model, fplayer, x, y, z, c1, c2 )
{
    local player = FindPlayer(fplayer);
    if (player) {
        local vehicle = CreateVehicle( model, Vector(x, y, z), player.Angle, c1, c2);
        player.Vehicle = vehicle;
        player.Frozen = false;
        Message("Vehicle angle returns: " + player.Angle);
    }
}

I'm just the new guy

!

function getVehicleAngle( veh )
{
  /* Check if vehicle exist */
  if ( !veh ) return;
 
  /* Get the index w of vehicle rotation */
  local quaternionW = Vehicle.Rotation.w;
 
  /* Check if it is not greater than 1 */
  if ( quaternionW > 1 ) quaternionW = 1;
 
  /* apply the formula to get the angle in radians from quaternion */
  local radian = 2 * acos( quaternionW );
 
  /* return the result */
  return radian;
}

/* Some other conversions by an unknown user */
function DegtoRad(  degree ) return degree * 0.0174533;
function RadtoDeg( radian ) return radian * 57.2958;

Discord: zeus#5155

Mötley

That Method oddly doesn't always return the right angle 80% of the time, for example whenever the vehicle is upside down, the angle will return the wrong angle if you flip the vehicle, I can run this on a timer whenever i'm in vehicle to use that method and I will eventually face the wrong way vs what I posted. I only posted this as a general thing to fix as it would be helpful and a good way to do away with that method

D4rkR420R

Jeez, you're a buzzkill. You can use vehicle.Rotation = Quartenion( 0.0, 0.0, 0.0, 0.0 ). It's the legit way to do it.


Mötley

I noted
QuoteThat Method oddly doesn't always return the right angle 80% of the time,

!

Quote from: Motley on Oct 04, 2018, 12:27 PMI noted
QuoteThat Method oddly doesn't always return the right angle 80% of the time,
returns 100% accurate in all cases.

Discord: zeus#5155

Mötley

Make your vehicle sit upside down and reset it by setting the vehicle position to be the same as the vehicle position, and set the angle that it gave you.

Do that and tell me your results. It's not 100% accurate, as I said I can drive down the road and use that method on a timer to set the angle to be the same as that angle gives me for the vehicle and it will return a different angle at times. Don't really know why this went from what I posted to everything after, Was mentioned since this is a easy fix as while in vehicle player status needs to be resetted or something like that

!

Well I was not talking about the angle it was about the vehicle rotation( it returns values 100% accurate ) but if you do want to flip the vehicle while its angle is same as before there is a snippet which will provide a little help.

https://forum.vc-mp.org/?topic=5758.msg41727#msg41727


I do know the main aim of the topic is to alert dev to implement the suggestion of allowing player angle to be synced while in vehicle but I would request to remove the temp solution although it is a simple hack to get around but not a better way of doing it like this.

Discord: zeus#5155

Mötley

That method returns the wrong angle as well during vehicle flip :'(

I promise I'm not frowning upon or anything I just want to keep this on topic as much as possible that's all.

What do you mean by which solution?
Quotebut I would request to remove the temp solution although it is a simple hack to get around but not a better way of doing it like this.