Jump to content
Sign in to follow this  
wok

Waypoints arrow style using DrawIcon 3D

Recommended Posts

I have been testing the drawIcon3D command, here's my test code:

onEachFrame {
{
	drawIcon3D ["", [0,1,0.5,0.4], [getPos _x select 0, getPos _x select 1, 2], 1, 1, 45, "", 1, 0.03, "default"];
} foreach allunits;
};

I have two questions:

1) Is it possible to have arrows on the sides of the screen pointing at the icon direction when you are not looking at it? Sort of like what you see with squad members, or waypoints.

2) Is there any way to make the icons movement smoother? The squad hexagon looks much smoother than drawIcon3D icons.

EDIT:

Solved (2) using visiblePosition instead of getPos.

Share this post


Link to post
Share on other sites

I still couldn't find a solution for (1), so I am thinking about doing the arrows myself, but I would need to find a way to know when the icon (or unit) gets "outside the screen", does anyone knows a way for doing this?

Also is there any command like drawIcon3D but for 2D stuff? I mean I usually use dialogs and RscTitles for hud and overlay stuff, but that's not as simple as drawIcon3D which you can use to do all in one line of code.

Share this post


Link to post
Share on other sites

I made some progress, after a few hours of learning trigonometry I found the existence of BIS_fnc_dirTo, so I am using that to make the arrows point to certain angle, the basic code looks like (to use place it on a init.sqf file, and place a few units on the map and make sure you are in 3rd person view):

onEachFrame {
   {
           if( _x != player ) then {
                   _angle = ( ( getDir player) - ( [player, _x] call BIS_fnc_dirTo ) );
                   drawIcon3D ["\A3\ui_f\data\map\Markers\Military\arrow2_ca.paa", [1, 1, 1, 0.7], [visiblePosition player select 0, visiblePosition player select 1, 2], 1, 1, _angle, "", 0, 0.03, "default"];
           };
   } foreach allUnits;
};

That kinda works, but all the icons are bunched up on the same position, so I though about making them move around a circle which center would be the player, after doing some more research I found this:

Given a radius length r and an angle t in radians and a circle's center (h,k), you can calculate the coordinates of a point on the circumference as follows (this is pseudo-code, you'll have to adapt it to your language):

float x = r*cos(t) + h;
float y = r*sin(t) + k;

Since I have all those values I translated that to arma:

onEachFrame {
   {
           if( _x != player ) then {
                   _angle = ( ( getDir player ) - ( [player, _x] call BIS_fnc_dirTo ) );
                   _circle_center_x = visiblePosition player select 0;
                   _circle_center_y = visiblePosition player select 1;
                   _x = 0.5 * cos(_angle) + _circle_center_x;
                   _y = 0.5 * sin(_angle) + _circle_center_y;
                   drawIcon3D ["\A3\ui_f\data\map\Markers\Military\arrow2_ca.paa", [1, 1, 1, 0.7], [_x, _y, 2], 1, 1, _angle, "", 0, 0.03, "default"];
           };
   } foreach allUnits;
};

The result looks like this:

amo9uc9.png

It does work but is not exactly the effect I am looking for. If you rotate your player around you can notice the arrows moving within a circle, but the circle is obviously a 3D circle around the player, I want it to be a 2D circle on the middle of the screen. And the second problem, the arrow is on the opposite side it should be in the circle, when an unit is on your left, the arrow that correspond to that unit is on the right side of the circle, same thing with front and back, etc.

I am trying to achieve something like (or exactly) what Payday 2 has:

mGxWJVF.png

Please some expert have mercy on me and share your knowledge. How could I make the arrows move around a 2D circle like in payday?

Edited by wok

Share this post


Link to post
Share on other sites

there is:

scriptName "Functions\geometry\fn_relativeDirTo.sqf";
/************************************************************
Relative Direction To
By Andrew Barron

Parameters: [object 1, object or position 2]

Returns the relative direction from object 1 to
object/position 2. Return is always 0-360.

A position to the right of unit would be at a relative direction of 90 degrees, for example.

Example: [player, getpos dude] call BIS_fnc_relativeDirTo
************************************************************/

if your result are opposite what you want, you can just subtract 180 from the angle and adjust if necessary

_angle = _angle - 180;
if (_angle < 0) then {_angle  _angle + 360};

I'm not sure if there is any way you can update UI elements as fast as Draw3D

Edited by Kunsa
0.0

Share this post


Link to post
Share on other sites

Thanks a lot for replying, I was feeling lonely here.

The angle of the arrows is not the problem, what's wrong is their position on the circle they move around the player, here's a video to illustrate that, and other problems.

(So sorry for the bad quality (I added some yt filter that makes it a little better but it still is potatoe quality), my upload speed is so bad it took me like 5 hours to upload these 60 seconds of video, it would take me more than a day to upload one if high quality. The first 30 seconds of the video are a test with units at close range, the last 30 seconds is a test with units at longer distance.)

I gotta go out now but I will post an update later (in about 4 or 5 hours if I can make it, or tomorrow) with the code and the current issues I am trying to solve.

Share this post


Link to post
Share on other sites

Wok,

I'm trying to build a target indication system for tanks in ARMA 3 and would like to use a system similar to what you have here. PM sent as well.

Share this post


Link to post
Share on other sites
Wok,

I'm trying to build a target indication system for tanks in ARMA 3 and would like to use a system similar to what you have here. PM sent as well.

I haven't received any pm so I am replying here, here's another related thread with some snippets that try to solve some issues: http://forums.bistudio.com/showthread.php?168525-Calculating-point-in-circle-circunference-gives-always-same-result

I don't have my gaming pc running so I can't search for my test missions, I will try to connect that hdd later and dig them out. If I don't remember try sending me a pm.

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
Sign in to follow this  

×