CreativeProduct 2 Posted August 19, 2017 Hello there! I was trying to Visualize a Marker by having objects placed at the edge of that specific marker. Using SHK_Pos its done in no time at all. Now, the problem is, that the Markers Size reduces over time and the created objects (in my case Cones) should continue to be at the edge of the marker while the marker is shrinking. The "shrinking" paprt works, but not perfectly, as the cones end up in random places at the end (Screenshot) Im not quite sure what happening, so those are my Assumptions: Objects cant be spawned outside of the world (Eg. Black area outside of the chart) SHK_Pos Is not getting the correct position My Way of setting the position of the cones isnt accurate The cones get stuck on other objects liek buildings, messing up the positions. Me, not seeing the most obvious thing This is the Code im using. _Size is the Distance. - _DummyList is the Array of the Cones created - _Speed is 5. If (_SizeMarker > _Size) then { "Zone" setMarkerColor "ColorRed"; "Zone" SetmarkerSize [(_SizeMarker - _speed),(_SizeMarker - _speed)]; { if ( (_x distance (GetMarkerPos "Zone")) > _Size) then { _x setpos [(_x modelToWorld [0,_speed,0]) select 0, (_x modelToWorld [0,_speed,0]) select 1, 0]; }; } Foreach _DummyList; [_size, _DummyList] Execvm "Server\Zones\zoneScaling.sqf"; Sleep 0.1; } else {"Zone" setMarkerColor "ColorBlue";}; I was trying the script in 50 Meters distance in which everything worked fine. The Script need to be run individually since the _Size Changes by a different script. Thanks in Advance, CP ~ Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted August 19, 2017 Made this now and working after a brief test. Using eachFrame eventhandler so the objects and marker are moving smooth. Should be ok if you're not using this for more than 10-15 vehicles at a time, maybe more. //init.sqf TAG_fnc_visualizeMarker = { params ["_unit","_marker"] _marker setMarkerColor "ColorRed"; missionNamespace setVariable ["TAG_fnc_visualizeMarkerObject",_unit]; TAG_fnc_markerObjects = []; TAG_fnc_markerSteps = 20; _step = 360/TAG_fnc_markerSteps; _spawnpos = getposatl _unit vectoradd [0,0,200]; for "_i" from 1 to 360 step _step do { _object = "RoadCone_L_F" createVehicle _spawnpos; _object enablesimulation false; TAG_fnc_markerObjects pushback _object; _object setposatl (vehicle _unit getrelpos [20,_i]); }; addMissionEventHandler ["eachFrame",{ _unit = missionNamespace getVariable ["TAG_fnc_visualizeMarkerObject",objnull]; _marker = "Zone"; _speed = speed _unit * 0.277778;//convert this to m/s for better visuals _distance = _speed max 10;//smallest size will be 10 _marker setMarkerColor "ColorRed"; _marker SetmarkerSize [_distance,_distance]; _marker setMarkerPos getposasl _unit; _step = 360/TAG_fnc_markerSteps; TAG_fnc_markerObjects apply {_x setposatl ((vehicle _unit getrelpos [_distance,((TAG_fnc_markerObjects find _x) * _step)]))} }]; }; //call function [player,"Zone"] call TAG_fnc_visualizeMarker; For using a custom size variable simply replace the distance one inside the eventhandler. Cheers Share this post Link to post Share on other sites
CreativeProduct 2 Posted August 19, 2017 21 minutes ago, Grumpy Old Man said: Made this now and working after a brief test. Using eachFrame eventhandler so the objects and marker are moving smooth. Should be ok if you're not using this for more than 10-15 vehicles at a time, maybe more. //init.sqf TAG_fnc_visualizeMarker = { params ["_unit","_marker"] _marker setMarkerColor "ColorRed"; missionNamespace setVariable ["TAG_fnc_visualizeMarkerObject",_unit]; TAG_fnc_markerObjects = []; TAG_fnc_markerSteps = 20; _step = 360/TAG_fnc_markerSteps; _spawnpos = getposatl _unit vectoradd [0,0,200]; for "_i" from 1 to 360 step _step do { _object = "RoadCone_L_F" createVehicle _spawnpos; _object enablesimulation false; TAG_fnc_markerObjects pushback _object; _object setposatl (vehicle _unit getrelpos [20,_i]); }; addMissionEventHandler ["eachFrame",{ _unit = missionNamespace getVariable ["TAG_fnc_visualizeMarkerObject",objnull]; _marker = "Zone"; _speed = speed _unit * 0.277778;//convert this to m/s for better visuals _distance = _speed max 10;//smallest size will be 10 _marker setMarkerColor "ColorRed"; _marker SetmarkerSize [_distance,_distance]; _marker setMarkerPos getposasl _unit; _step = 360/TAG_fnc_markerSteps; TAG_fnc_markerObjects apply {_x setposatl ((vehicle _unit getrelpos [_distance,((TAG_fnc_markerObjects find _x) * _step)]))} }]; }; //call function [player,"Zone"] call TAG_fnc_visualizeMarker; Cheers Hey there! Thanks for the code, but im afraid it' not what I am looking for, but it looks pretty interesting. So, let me try to clear some things up. Hopefully, duh. I have created a marker, that marker decreases in Size (only in size, Center stay in the same place) after a while (similar to a Zone restriction). Since I cant attach those cones to the edge of the marker I need to move them Manually. SO I set them facing into the center and then doing my ModelToWorld magic trick. However, as seen in the pic, the positions are getting messed up. Either the cones arent the exact same distance to the center, or something "interrupts" the movement. Thanks again for your suggestion, CP~ Share this post Link to post Share on other sites
CreativeProduct 2 Posted August 19, 2017 Alright, I found a solution to my problem. It Seems as the Command GetPos got a new way to use it with a second parameter being the direction. I solved my problem by doing this: By Preseting _dir to 0. if ( (_x distance (GetMarkerPos "Zone")) > _Size) then { _dir = _dir + 3; _pos = (Getmarkerpos "Zone") Getpos [(_SizeMarker - _Speed), _dir]; _x setpos _pos; }; Thanks for the help, I really Appreciate it! Love, CP~ 1 Share this post Link to post Share on other sites