Jump to content

.


Fabio132

Recommended Posts

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 comment
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 comment
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...