Jump to content
Sign in to follow this  
gossamersolid

3D Credits Function help

Recommended Posts

When using the 3D Credits function (Included in 1.56), it places the text really high above the object it's attached to and as you move closer it moves the text down, but if you move further away it moves the text up.

I'd like it so that the text was in a static height above the object I have it attached to.

I've tried to modify the function, but to no luck. I hate working with GUI things in this game as I can never get anything to work right :)

Here's the code from the original function:

/*
Author: Karel Moricky

Description:
3D credits.

Parameter(s):
_this select 0: STRING - Text
_this select 1: ARRAY - Position in 3D world

Returns:
True
*/
disableserialization;
private ["_text","_pos","_display","_control","_w","_h","_m insDis","_dis","_alpha","_pos2D"];

_text = _this select 0;
_pos = _this select 1;
_minDis = if (count _this > 2) then {_this select 2} else {20};
_fadeDis = if (count _this > 3) then {_this select 3} else {1.5};
if (isnil "BIS_fnc_3dCredits_n") then {BIS_fnc_3dCredits_n = 2733;};

if (typename _pos == typename objnull) then {_pos = position _pos};
if (typename _pos == typename "") then {_pos = markerpos _pos};

BIS_fnc_3dCredits_n cutrsc ["rscDynamicText","plain"];
BIS_fnc_3dCredits_n = BIS_fnc_3dCredits_n + 1;

//#define DISPLAY (uinamespace getvariable "BIS_dynamicText")
//#define CONTROL (DISPLAY displayctrl 9999)

_display = uinamespace getvariable "BIS_dynamicText";
_control = _display displayctrl 9999;

#define DISPLAY _display
#define CONTROL _control

CONTROL ctrlsetfade 1;
CONTROL ctrlcommit 0;
CONTROL ctrlsetstructuredtext parsetext _text;
CONTROL ctrlcommit 0;

_w = safezoneW;//0.5;
_h = safezoneH;//0.3;

while {true} do {
_dis = player distance _pos;
_alpha = abs ((_dis / _minDis) - _fadeDis);

if (_alpha <= 1) then {
_pos2D = worldtoscreen _pos;

if (count _pos2D > 0) then {
CONTROL ctrlsetposition [
(_pos2D select 0) - _w/2,
(_pos2D select 1) - _h/2,
_w,
_h
];
//CONTROL ctrlsetbackgroundcolor [0,0,0,0.5];
CONTROL ctrlsetstructuredtext parsetext _text;
CONTROL ctrlsetfade (_alpha^3);
CONTROL ctrlcommit 0.01;
} else {
CONTROL ctrlsetfade 1;
CONTROL ctrlcommit 0.1;
};
} else {
CONTROL ctrlsetfade 1;
CONTROL ctrlcommit 0.1;
sleep 0.1;
};
sleep 0.01;
};

Share this post


Link to post
Share on other sites
Try changing this:

(_pos2D select 1) - _h/2,

to

(_pos2D select 1),

That's making progress, but now it presents a new issue. The icon appears at the bottom of the unit's feet (actually a little lower).

Since we've got this working, I now need to somehow figure out how to get it to place the text a little above the unit's head.

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  

×