Jump to content

entity


sui228

Recommended Posts

Entities.Players.GetAtHandle(entityHit); and Entities.Vehicles.GetAtHandle(entityHit); doesn't work.

I use GetShapeTestResult();

int ray = GetEntityRay(...);
int isHit = 0;
int entityHit = 0;
int result = Shapetest.GetShapeTestResult(ray, ref isHit, new Vector3(0, 0, 0), new Vector3(0, 0, 0), ref entityHit);

And when I try to use Entities.Players.GetAtHandle(entityHit) and Entities.Vehicles.GetAtHandle(entityHit), an error occurs:

switch (RAGE.Game.Entity.GetEntityType(entityHit))
            {
                default:
                    return null;
                case 1:
                    return RAGE.Elements.Entities.Players.GetAtHandle(entityHit);
                case 2:
                    return RAGE.Elements.Entities.Vehicles.GetAtHandle(entityHit);
            }
Цитата

Object reference not set to an instance of an object.

What should I do?

I think GetShapeTestResult () doesn't return the handle of the entity, but something else.

Link to comment
Share on other sites

UPD: I didn't find a solution to the problem, but I realized that the entity I get has the correct handle, but the GetAtHandle function doesn't work correctly. instead of a solution I made a kind of crutch:

public static Player GetPlayerByHeading(float heading)
        {
            List<Player> players = Entities.Players.Streamed;
            Player player = null;
            foreach(var plr in players)
            {
                if (plr.GetHeading() == heading)
                {
                    player = plr;
                    break;
                }
            }
            return player;
        }

 

  • Like 1
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...