Skip to main content

Vector3Extensions


Namespace: FivePD.API.Utils#
File: Source/Utils/Vector3Extensions.cs#

Methods#

Around#

Returns a random Vector3 (relative to the specified position), within a given radius.

Type:string

Example#

Vector3 position = Game.PlayerPed.Position.Around(175f);

RandomXy#

Returns a normalized Vector3 with random X and Y coordinates.

Example#

Vector3 position = Vector3Extension.RandomXy();

DistanceTo#

Returns the distance between 2 points.

Params:

  • source
    • Type: Vector3
    • Original position
  • target
    • Type: Vector3
    • Target position

Example#

Ped targetPed;...float distanceTo = Game.PlayerPed.Position.DistanceTo(targetPed.positon);

ApplyOffset#

Returns a Vector3 with the given offset applied on it.

Params:

  • source
    • Type: Vector3
    • Source position
  • offset
    • Type: Vector3
    • Offset value

Example#

Vector3 offsetPos = Game.PlayerPed.Position.ApplyOffset(new Vector3(4.5f,3.0f,2.6f));

GroundHeight#

Returns the height of the given position.

Params:

  • source
    • Type: Vector3
    • Source position

Example#

float gHeight = Game.PlayerPed.Position.GroundHeight();

ClosestStreetName#

Returns the closest street name.

Params:

  • source
    • Type: Vector3
    • Source position

Example#

string street = Game.PlayerPed.Position.ClosestStreetName();

SetWaypointHere#

Sets the player's waypoint to the given position.

Params:

  • source
    • Type: Vector3
    • Source position

Example#

new Vector3(10f,10f,10f).SetWaypointHere(); // Will set a waypoint at that position

ClosestPedPlacement#

Returns the closest position (relative to the given position) where a ped can be placed on the sidewalk.

Params:

  • source
    • Type: Vector3
    • Source position

Example#

Vector3 position = new Vector3(10f,10f,10f).ClosestPedPlacement();

ClosestParkedCarPlacement#

Returns the closest position (relative to the given position) where a vehicle be placed on the side of the road.

Params:

  • source
    • Type: Vector3
    • Source position
  • unoccupied
    • Type: bool (default: true)
    • If true, only unoccupied spots will be searched

Example#

Vector3 position = new Vector3(10f,10f,10f).ClosestParkedCarPlacement(false);

GetClosestParkedCar#

Returns the closest parked vehicle (relative to the given position).

Params:

  • source
    • Type: Vector3
    • Source position

Examples#

Vehicle vehicle = new Vector3(10f,10f,10f).GetClosestParkedCar();