Jump to content
RAGE Multiplayer Community

How to use raycasting in c#?


Recommended Posts

I need to know the distance to the transport when I look at it.

In JavaScript it would look something like this:

mp.raycasting.testPointToPoint(first position, second position, mp.players.local);

But I didn't find it in c#.

How to use raycasting in c#?

I thank you all in advance.

Edited by sui228
i complemented this theme
Link to post
Share on other sites
  • 3 months later...
  • 2 months later...
В 03.03.2021 в 02:36, horex сказал:

Can you tell me a solution?

RAGE.Game.Shapetest  == mp.raycasting

Vector3 headPos = player.GetBoneCoords(31086, 0.0f, 0.0f, 0.0f);
            Vector3 offsetPos = RAGE.Game.Entity.GetOffsetFromEntityInWorldCoords(player.Handle, 0.0f, 20.0f, -10.0f);
            RAGE.Game.Graphics.DrawLine(headPos.X, headPos.Y, headPos.Z, offsetPos.X, offsetPos.Y, offsetPos.Z, 255, 0, 0, 255);
            int resultShape = RAGE.Game.Shapetest.StartShapeTestRay(headPos.X, headPos.Y, headPos.Z, offsetPos.X, offsetPos.Y, offsetPos.Z, 1, player.Handle, 7);

            int hit = -1;
            Vector3 endCoords = new Vector3();
            Vector3 surfaseNormal = new Vector3();
            int endEndidty = -1;

            int result = RAGE.Game.Shapetest.GetShapeTestResult(resultShape, ref hit, endCoords, surfaseNormal, ref endEndidty);
            if(result != 0)
                RAGE.Game.Graphics.DrawMarker(28, endCoords.X, endCoords.Y, endCoords.Z, 0.0f, 0.0f, 0.0f, 0.0f, 180.0f, 0.0f, 0.2f, 0.2f, 0.2f, 255, 128, 0, 50, false, true, 2, false, null, null, false);

spacer.png

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