miguel93041 0 Posted August 26, 2016 Description When we use the modelToWorld combined with worldToScreen in moving vehicles the position given its not the correct one.Its caused by a velocity error acting with worldToScreen causing for example: If our modelToWorld is at [0,2,0] // In a AH-9 helicopterand we use worldToScreen to transform the coordinates into x,y positions and it give us 1,1... when the vehicle starts to move it changes to 1.5,1.5 or 2,2 and not in 1,1 then we cant use them. This video is not the bug that im having but it describes how the worldToScreen x,y positions are moving into a bad one. STEPS TO REPRODUCE You can create an script like this one that is an interaction cockpit system. 1. Create a sqf file and name it to pfh_click.sqf Put this in: //if the player isn't in a helicopter then we don't run this if(vehicle player iskindof "Helicopter") then { _heli = vehicle player; if(isNil "button_clicked") then {button_clicked = 0;}; //keeps our key from constantly having an effect - that is, press it once and it won't do anything again until released and pressed again _controlpos = worldToScreen (_heli modelToWorldVisual [0,2,0]); if(count _controlpos < 2) then {_controlpos = [-100,-100];}; //if the point is outside of our FOV then set it to something ridiculous _hinttext = "No Action"; //basic hint to indicate what we're looking at player sidechat format ["%1",_controlpos]; //debugging - shows position of a control on screen coordinates; the closer to 0.5,0.5, the closer it is to the center of the screen if(_controlpos distance [0.5,0.5] < 0.025) then {_hinttext = "Toggle Engine";}; //change hint to engine on if(!(_hinttext == "")) then {hintsilent format ["%1",_hinttext];}; //set our hint text if(_hinttext == "No Action") exitwith {}; //if no action available then we don't need to do anything so quit //check to see if our action is within the right parameters and that the key has been pressed, then do something if(inputaction "User20" > 0.1 && button_clicked == 0 && _controlpos distance [0.5,0.5] < 0.01) then { if(isengineon _heli) then { player action ["EngineOff", _heli]; } else { player action ["EngineOn", _heli]; }; button_clicked = 1; }; //clear our key press if it's not being pressed if(inputaction "User20" < 0.5) then { button_clicked = 0; }; }; What it does, it takes a model position to a world one then it takes the world position to screen coordinates, so when aim with your screen (0.5,0.5) at that point it hint you "Toggle engine" and if you press the "Custom key 20" it starts the engine.But if you arent aiming at the point it hint you "No action" 2. Spawn an AH-9 helicopter 3. Put this in the debug console (ESC) and execute it my_clickaction = compile preprocessFileLineNumbers "pfh_click.sqf"; ["my_clickid", "onEachFrame", "my_clickaction"] call BIS_fnc_addStackedEventHandler; ADDITIONAL INFORMATION Its good to have this working correctly so people can create interaction systems Share this post Link to post Share on other sites
pierremgi 4740 Posted September 18, 2016 Did you try modelToWorldVisual ? 1 Share this post Link to post Share on other sites