Jump to content
RAGE Multiplayer Community

Get Player That Player point at


Recommended Posts

Hello,

I wanna make a Menu to give Money and other things but i dont find any function for getting player that i pointing at in js.
I want to return the player that i point at Example:

let target = player.pointat();

target.setVariable('test',1);

When you find a function like this pls help me

Thanks for Reading and your Help.

Link to post
Share on other sites
vor 6 Minuten schrieb Kopra:

Okay but did you try with player.Heading?

Player::heading - RAGE Multiplayer Wiki It says here that it returns facing angle in degree, but I'm not sure how accurate that is but I think that you will have to experiment yourself because I can not find any default functions like you described in first post.

Yeah, it seems like it doesn't exists a function like that. But thanks for your help.

  • Like 1
Link to post
Share on other sites
you can use Raycasting

 

here's a example on wiki

https://wiki.rage.mp/index.php?title=Raycasting::testPointToPoint


 

 

function pointingAt(distance) {
    const camera = mp.cameras.new("gameplay"); // gets the current gameplay camera

    let position = camera.getCoord(); // grab the position of the gameplay camera as Vector3

    let direction = camera.getDirection(); // get the forwarding vector of the direction you aim with the gameplay camera as Vector3

    let farAway = new mp.Vector3((direction.x * distance) + (position.x), (direction.y * distance) + (position.y), (direction.z * distance) + (position.z)); // calculate a random point, drawn on a invisible line between camera position and direction (* distance)

    let result = mp.raycasting.testPointToPoint(position, farAway, null, 17); // now test point to point - intersects with map and objects [1 + 16]

    return result; // and return the result ( undefined, if no hit )
}

 

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...