Author Topic: player.Angle returns wrong angle sometimes  (Read 4167 times)

Motley

  • Full Member
  • ***
  • Posts: 253
  • Karma: +32/-34
    • View Profile
player.Angle returns wrong angle sometimes
« on: November 24, 2016, 09:30:28 pm »
I modified a command of mine to save locations, But for some reason player.Angle was set for the wrong angle.

I do not see anything wrong with the anlge, But why it returned a different angle surprises me,

 ??? Maybe it is because I used turret left and right key as well the mouse for perfected angle rather than walking and moving normally to where I want the angle to be?

I am using ini instead of print as I prefer to do this differently.
Code: [Select]
Count <- 0;
function onPlayerCommand( player, cmd, text ) {


   if ( cmd == "savepos" )
   {

       WriteIniFloat( "Locations.ini", GetDistrictName(player.Pos.x, player.Pos.y) + Count, "X", player.Pos.x );
       WriteIniFloat( "Locations.ini", GetDistrictName(player.Pos.x, player.Pos.y) + Count, "Y", player.Pos.y );
       WriteIniFloat( "Locations.ini", GetDistrictName(player.Pos.x, player.Pos.y) + Count, "Z", player.Pos.z );
       WriteIniFloat( "Locations.ini", GetDistrictName(player.Pos.x, player.Pos.y) + Count, "Angle", player.Angle );
 
       MessagePlayer( "Saved location " + GetDistrictName(player.Pos.x, player.Pos.y) + Count, player, Colour( 225, 225, 225 ) );
       Count++;

     return true;
  }

If you see anything wrong in my message or command please let me know  :)

Rhytz

  • Newbie
  • *
  • Posts: 30
  • Karma: +13/-7
    • View Profile
    • Rhytz's Website
Re: player.Angle returns wrong angle sometimes
« Reply #1 on: November 26, 2016, 01:12:47 pm »
Didn't you have to do some kind of calculation to get the correct angle? I remember seeing something like that a while ago
Meet everyone on the Liberty Unleashed Discord || Check out my website/portal!

JamesConway

  • Newbie
  • *
  • Posts: 39
  • Karma: +9/-3
    • View Profile
Re: player.Angle returns wrong angle sometimes
« Reply #2 on: November 26, 2016, 01:16:49 pm »
Didn't you have to do some kind of calculation to get the correct angle? I remember seeing something like that a while ago

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

Rhytz

  • Newbie
  • *
  • Posts: 30
  • Karma: +13/-7
    • View Profile
    • Rhytz's Website
Re: player.Angle returns wrong angle sometimes
« Reply #3 on: November 26, 2016, 02:51:02 pm »
Yeah that one, maybe that also applies to this?
Meet everyone on the Liberty Unleashed Discord || Check out my website/portal!

Motley

  • Full Member
  • ***
  • Posts: 253
  • Karma: +32/-34
    • View Profile
Re: player.Angle returns wrong angle sometimes
« Reply #4 on: November 30, 2016, 03:10:40 am »
EDITED AT The bottom

Maybe this is true,.,,

My current saved position is

[954.9, -833.8, 14.79, 152.0],

When I type save again on that spawned location I return this

[954.8, -833.8, 14.79, 2.50448e-006]

Weird...

My cmd

Code: [Select]
  if ( cmd == "save" )
  {
    MessagePlayer("[" + player.Pos.x + ", " + player.Pos.y + ", " + player.Pos.z + ", " + player.Angle + "],", player, PURPLE );
    print( "[" + player.Pos.x + ", " + player.Pos.y + ", " + player.Pos.z + ", " + player.Angle + "],")
  }

I tried that patch and it does not work.... I also can not manually change a players angle unless I do a over-top view of the player, Odd..

It's official when setting player.Angle it never calls for a update unless you use a over top view. Even The LoacationSaver script by force did this...

Also adding:

When setting a camera matrix in attempts to bypass this with a possibility of a really cool spawn

Code: [Select]
SetCameraMatrix( player, Vector( player.Pos.x, player.Pos.y + 3.42, player.Pos.z ), Vector( player.Pos.x, player.Pos.y, player.Pos.z ) );
player.Frozen = true;
SetCinematicBorder( true );

You can now manually set the angle.

Now th bad part.

Code: [Select]
  if ( cmd == "restore" )
  {
     RestoreCamera( player );
     SetCinematicBorder( false );
     player.Frozen = false;
  }

player.Angle is set to 270 regardless, WTF! why 270??

Maybe someone could help me bypass this and find a fix?
« Last Edit: December 01, 2016, 02:53:07 am by Mötley »

Theremin

  • Full Member
  • ***
  • Posts: 154
  • Karma: +48/-18
  • Worst Server Owner
    • View Profile
    • Visit my YouTube channel
Re: player.Angle returns wrong angle sometimes
« Reply #5 on: December 07, 2016, 02:34:36 am »
I did some tests, and I confirm what Motley says, I'd just like to sum it up:

- Vehicle.Angle gets value in degrees, and sets it in radians.
- Player.Angle gets and sets the value in degrees, but it doesn't change if the mouse is controlling the camera, this explains why it works if the player is in spawnscreen or using SetCameraMatrix, or using top-down view, and why it doesn't work with Player.Frozen since the mouse is still controlling the camera. Basically the mouse overrides Player.Angle settings.
- RestoreCamera always sets the angle to 270 degrees.
« Last Edit: December 07, 2016, 02:42:33 am by Theremin »

Motley

  • Full Member
  • ***
  • Posts: 253
  • Karma: +32/-34
    • View Profile
Re: player.Angle returns wrong angle sometimes
« Reply #6 on: December 07, 2016, 05:38:32 am »
on player.Angle the players angle is set to north, This can be proved by looking at the blip N "North" on the radar on spawn.

And the angle for north always returns '2.50448e-006' regardless of where you are, That's even more odd.

Therefore there is no way to actually set the players angle. Not even after restring the camera matrix after spawn, Nothing.

If anything you could spawn the player in a car onPlayerSpawn, But.. that would be a little dumb honestly.

And I still can not believe RestoreCamera always sets the angle to 270.

 

© Liberty Unleashed Team.