Sign in to follow this  

[Client JS] Clicksystem / Raycast Issue

Recommended Posts

Hey there,

I am trying currently to implement a simple click system. Just to explain my goal: I want for example that a player can click on an ATM (from original map - no spawned object) and a UI opens.

My code currently get's triggered by the playerclick event , but the player click event doesn't return an entity. So I thought, I could use Raycast to get the clicked object. But result of it is just a number.

Here my Question: What number is that and can this converted somehow to an entity, to change for example alpha (as debug) or to get the model hash of it?


Here my current code to maybe understand my problem a bit better:'click', (x, y, upOrDown, leftOrRight) => {
    let pos3d =[x, y]);
    const camera ="gameplay"); // gets the current gameplay camera
    let position = camera.getCoord();

    const end = lerp(position, pos3d, 5);
    const result = mp.raycasting.testPointToPoint(position, end, [mp.players.local]);
  	// here I have the problem:  result.entity is a number in case of a world object....'playerClick', x, y, upOrDown, leftOrRight, result ? result.entity : null);


Share this post

Link to post
Share on other sites

Okay, I found a solution. Just for people that have maybe same problem:

Thanks to Yoe on Discord, I know now that I can use simply entity natives for that and use the number result directly as entity for that natives.
So that I don't need Entity object for now :)

  • Like 1

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.