Jump to content
Sneax x

See player's drawIcon3D through walls

Recommended Posts

Hi,

i got the following drawIcon3D script that shows the players names above their heads:

onEachFrame {
  _units = nearestObjects[(visiblePosition player),["Man"], 17];
  _units = _units;

    {
    _color = switch (playerSide) do {
        case (EAST): {[1,0,0,1]};
        case (WEST): {[0,0,1,1]};
        case (independent): {[0,1,0,1]};
        case default {[2.55,0.55,0,10]};
    };
    if (side _x isEqualto playerSide) then {
      if (!(lineIntersects [getPos player, getPos _x, player, _x]) && alive _x) then {
        drawIcon3D [
          "",
          _color,
          [visiblePosition _x select 0,visiblePosition  _x select 1, (visiblePosition _x select 2) +((_x ModelToWorld (_x selectionPosition "player")) select 2)+ 1.83],
          45,
          -2,
          -1,
          name _x,
          2,
          0.035,
          "Puristamedium",
          "center"
        ];
      };
    };
  }forEach _units;
};

the problem: this shows also the names thought objects where i cant see the player normaly... how can i fix this? also it would be nice if my enime is in a car i would see his name above the car (not works now). 

Thx for your answer's 😄

Share this post


Link to post
Share on other sites

lineIntersect commands wait for ASL position. Try with lineIntersectsSurfaces (count = 0)

 

_units = nearestObjects[(visiblePosition player),["Man"], 17]; is not the best code for your aim and performance.

Try

_units = player nearEntities [["CAManBase","air","landVehicle","ship"], 17];  instead

 

 

  • Like 1

Share this post


Link to post
Share on other sites

checkVisibility will do the trick also.

  • Like 1

Share this post


Link to post
Share on other sites

Thx for your answere ! but it didnt changed something on the problem with the wall, also i can see players names if they are in a vehicle but if i get out i cant see their names if they are still in the vehicle, you have any other idears?

 

now the script looks like:

onEachFrame {
  _units = player nearEntities [["CAManBase","air","landVehicle","ship"], 17];
  _units = _units;

    {
    _color = switch (playerSide) do {
        case default {[2.55,0.55,0,10]};
    };
    if (side _x isEqualto playerSide) then {
      if (!( lineIntersects [getPos player, getPos _x, player, _x]) && alive _x) then {
        drawIcon3D [
          "",
          _color,
          [visiblePosition _x select 0,visiblePosition  _x select 1, (visiblePosition _x select 2) +((_x ModelToWorld (_x selectionPosition "player")) select 2)+ 1.83],
          45,
          -2,
          -1,
          name _x,
          2,
          0.035,
          "Puristamedium",
          "center"
        ];
      };
    };
  }forEach _units;
};

 @POLPOX i have no idea how i can add a checkVisibility pram to this

thx for your help!

 

(lineIntersectsSurfaces (count = 0)  didnt worked... allways called a error)

Share this post


Link to post
Share on other sites
2 hours ago, Sneax x said:

Thx for your answere ! but it didnt changed something on the problem with the wall, also i can see players names if they are in a vehicle but if i get out i cant see their names if they are still in the vehicle, you have any other idears?

 

(lineIntersectsSurfaces (count = 0)  didnt worked... allways called a error)

 

Sure lineIntersectsSurfaces (count = 0) never worked as is. That demands a little reading on Biki. Same for ASL positions, you don't understand.

 

try:

onEachFrame {
  _units = player nearEntities [["CAManBase","air","landVehicle","ship"], 17];
  _units = _units - [player];
    {
    _color = switch (playerSide) do {
        case (EAST): {[1,0,0,1]};
        case (WEST): {[0,0,1,1]};
        case (independent): {[0,1,0,1]};
        case default {[2.55,0.55,0,10]};
    };
    if (side _x isEqualto playerSide) then {
      if (([player,"view", _x] checkVisibility [eyePos player,getPosASL vehicle _x])>0 && alive _x) then {
        drawIcon3D [
          "",
          _color,
          [visiblePosition _x select 0,visiblePosition  _x select 1, (visiblePosition _x select 2) +((_x ModelToWorld (_x selectionPosition "player")) select 2)+ 1.83],
          45,
          -2,
          -1,
          name _x,
          2,
          0.035,
          "Puristamedium",
          "center"
        ];
      };
    };
  }forEach _units;
};

 

  • Like 1

Share this post


Link to post
Share on other sites

hey... i played a lot with this and the problem is: this only checkVisibility from eyePos player.. how can i change it to third person player cam? i tryed with !( lineIntersects [ AGLToASL positionCameraToWorld[ 0, 0, 0 ], eyePos _units, cameraOn, _units ]) but it is not working!

Share this post


Link to post
Share on other sites

[player,"view", _x] checkVisibility [AGLToASL positionCameraToWorld[ 0, 0, 0 ],getPosASL vehicle _x]

 

works fine imho.

Share this post


Link to post
Share on other sites

I don't know why you say that. I have no problem with that. Don't forget, the 3rd view camera is behind the unit played. So, when you turn the head, your camera moves but the script does exactly what it's intended to do. After that, I probably don't understand your final aim.

Share this post


Link to post
Share on other sites

I dont know why... know how it with 3rd view works... could you please send me your complett script? maybe i replaced something wrong?

 

my looks:

onEachFrame {
  _units = player nearEntities [["CAManBase","air","landVehicle","ship"], 17];
  _units = _units - [player];
    {
    _color = switch (playerSide) do {
        case (EAST): {[1,0,0,1]};
        case (WEST): {[0,0,1,1]};
        case (independent): {[0,1,0,1]};
        case default {[2.55,0.55,0,10]};
    };
    if (side _x isEqualto playerSide) then {
      if (([player,"view", _x] checkVisibility [AGLToASL positionCameraToWorld[ 0, 0, 0 ],getPosASL vehicle _x])>0 && alive _x) then {
        drawIcon3D [
          "",
          _color,
          [visiblePosition _x select 0,visiblePosition  _x select 1, (visiblePosition _x select 2) +((_x ModelToWorld (_x selectionPosition "player")) select 2)+ 1.83],
          45,
          -2,
          -1,
          name _x,
          2,
          0.035,
          "Puristamedium",
          "center"
        ];
      };
    };
  }forEach _units;
};

and it is not working!

Picture

Share this post


Link to post
Share on other sites
onEachFrame {
  _units = player nearEntities [["CAManBase","air","landVehicle","ship"], 17];
  _units = _units - [player];
    {
    _color = switch (playerSide) do {
        case (EAST): {[1,0,0,1]};
        case (WEST): {[0,0,1,1]};
        case (independent): {[0,1,0,1]};
        case default {[2.55,0.55,0,10]};
    };
    if (side _x isEqualto playerSide) then {
      if (([player,"view", _x] checkVisibility [AGLToASL positionCameraToWorld[0,0,0],getPosASL vehicle _x])>0) then {
        drawIcon3D [
          "",
          _color,
          [visiblePosition _x select 0,visiblePosition  _x select 1, (visiblePosition _x select 2) +((_x ModelToWorld (_x selectionPosition "player")) select 2)+ 1.83],
          45,
          -2,
          -1,
          name _x,
          2,
          0.035,
          "Puristamedium",
          "center"
        ];
      };
    };
  }forEach _units;
};

 

But, you can use the stackable version:
 

["myCodeForTags", "onEachFrame", {
  _units = player nearEntities [["CAManBase","air","landVehicle","ship"], 17];
  _units = _units - [player];
    {
    _color = switch (playerSide) do {
        case (EAST): {[1,0,0,1]};
        case (WEST): {[0,0,1,1]};
        case (independent): {[0,1,0,1]};
        case default {[2.55,0.55,0,10]};
    };
    if (side _x isEqualto playerSide) then {
      if (([player,"view", _x] checkVisibility [AGLToASL positionCameraToWorld[0,0,0],getPosASL vehicle _x])>0) then {
        drawIcon3D [
          "",
          _color,
          [visiblePosition _x select 0,visiblePosition  _x select 1, (visiblePosition _x select 2) +((_x ModelToWorld (_x selectionPosition "player")) select 2)+ 1.83],
          45,
          -2,
          -1,
          name _x,
          2,
          0.035,
          "Puristamedium",
          "center"
        ];
      };
    };
  }forEach _units;
}] call BIS_fnc_addStackedEventHandler;

 

 

 

  • Like 2

Share this post


Link to post
Share on other sites

_x selectionPosition "player" would be [0,0,0], the same as any non existent selection. So basically the whole 

 

(visiblePosition _x select 2) +((_x ModelToWorld (_x selectionPosition "player")) select 2)+ 1.83

 

is just 

 

(visiblePosition _x select 2) + 1.83

  • Like 2

Share this post


Link to post
Share on other sites

I duno why, sometimes there are invisible unwanted characters in forum editor. Copying/pasting can fail and throw errors in Arma. Usually, in debug console or other editor, you can track them moving the cursor. This one seems to stay twice at a character, while scanning the code. You can remove them. But that could be nice if this problem would be solved here.

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×