Hello,
I'm having a hard time figuring this out, fiddling with an ufo script.
Basically I created an ufo texture divided in 16 pieces, each showing ingame on a respective "UserTexture10m_F".
(I'm aware that there's a bunch of vehicle addons but I don't want to rely on these. I also tried to attach a bunch of submarines in circle but it ended up nor looking good, nor fps friendly...)
So I have made a 5 texture variants to mimic ufo pitch, when reaching defined distances, it swaps the textures of each pannels.
These 16 "UserTexture10m_F" vehicles are attached to a basic can that is attached to a heli flying 2km above.
Looking good so far, problem is the texture is only showing on one face, distorting it before it disapears when passing by.
Now I'd want this whole 40m custom texture pannel to always face the player.
Unfortunately when I try to apply setVectorDirAndUp to that can, the whole ufo's texture setup is doing a constant 360flip.
Edit : So, I've digged some more but didn't felt doing core math would do good with my brain. Thankfully I came across MrSanchez helmet lamp mod that is (I think) aiming me towards the right spot, as I was also stumbling with pitching a custom flashlight up or down it's still kind of related and though of pasting it here aswell. I'll update as soon as I get the main subject working (if I ever do).
// all credits goes to MrSanchez
SAN_fnc_adjustLamp = {
params ["_unit","_lamp","_dir","_pitch"];
_vuz = cos _pitch;
_lamp setVectorDirAndUp [[(sin _dir) * _vuz,(cos _dir) * _vuz,sin _pitch], [0,0,_vuz]];
};
flashlightOn = false;
_light = "Reflector_Cone_01_narrow_white_F";// contact dlc
if (isClass (configFile >> "CfgVehicles" >> _light)) then {
playerFlashLight = createVehicle [_light, [0,0,50000], [], 0, "CAN_COLLIDE"];
playerFlashLight setDir (getDir player);
playerFlashLight allowDamage false;
playerFlashLight hideObjectGlobal true;
playerFlashLight attachTo [player, [0.2,0.4,0.04],"head"];
while {(alive player)} do {
waitUntil {(inputAction "headlights" > 0)};// press flashlight key ("L") to do the magic
playerFlashLight hideObjectGlobal false;
flashlightOn = true;
[] spawn {
while {(flashlightOn)} do {
if (currentWeapon player != "") then {
playerFlashLight attachTo [player, [0.2,0.4,0.04],"head"];
}else{
playerFlashLight attachTo [player, [-0.1,0.20,-0.14],"RightShoulder"];
};
_cameraVector = getCameraViewDirection player;
[player,playerFlashLight,0,(_cameraVector select 2)*90] call SAN_fnc_adjustLamp;
sleep 0.05;
};
};
waitUntil {(inputAction "headlights" == 0)};
waitUntil {(inputAction "headlights" > 0)};
playerFlashLight hideObjectGlobal true;
flashlightOn = false;
waitUntil {(inputAction "headlights" == 0)};
};
};
Edit 2 : I came across a snippet by reddit user Commy2, tho I can't figure how to get it to work properly. Those vectors are driving me nuts. Almost there I think, at least my ufo stopped spinning & follows given target but there's an offset growing as the target gets further away :/