Geramy92 Posted January 28, 2019 Share Posted January 28, 2019 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: mp.events.add('click', (x, y, upOrDown, leftOrRight) => { let pos3d = mp.game.graphics.screen2dToWorld3d([x, y]); const camera = mp.cameras.new("gameplay"); // gets the current gameplay camera let position = camera.getCoord(); const end = lerp(position, pos3d, 5); //@ts-ignore 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.... mp.events.callRemote('playerClick', x, y, upOrDown, leftOrRight, result ? result.entity : null); }); Link to comment Share on other sites More sharing options...
Geramy92 Posted February 2, 2019 Author Share Posted February 2, 2019 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 1 Link to comment Share on other sites More sharing options...
Freamee Posted October 19, 2019 Share Posted October 19, 2019 how do u get the object id from the click Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now