Client side urgent help needed xxxxx

Started by (vG)DesTroYeR^, Oct 19, 2025, 04:33 PM

Previous topic - Next topic

(vG)DesTroYeR^

does:
player.Angle
exist in client side? Simply, that was the question which I wanted to ask.

vitovc

#1
there is no clientside player.Angle but you can 1) get it from server (with lag) with Stream function 2) or you can guess player's camera angle (it almost same as player.Angle when player is not looking back)

get_angle <- function(x, y, x2, y2){
  return ::atan2(y2 - y, x2 - x);
}
get_player_angle <- function(){
  local screen_size = ::GUI.GetScreenSize();
  local cam_from = ::GUI.ScreenPosToWorld(::Vector(screen_size.X * 0.5, screen_size.Y * 0.5, -1));
  local cam_to = ::GUI.ScreenPosToWorld(::Vector(screen_size.X * 0.5, screen_size.Y * 0.5, 1));
  return ::get_angle(cam_from.X, cam_from.Y, cam_to.X, cam_to.Y);
}
untested, I took code from Get player Camera zoom
local angle = ::get_player_angle();also maybe you will need to add some offset to result of angle to make it similar as serverside angle, to do it correctly use
normalize_angle <- function (a){
  return ::atan2(::sin(a), ::cos(a));
}

::normalize_angle(angle + 1.57079);
...::: vice city :::...
Useful things for vcmp: Relative position and finding an angle (in 3d), 3d line (like laser)