Search the Community
Showing results for tags 'setpos'.
Found 11 results
-
How to constantly spin/rotate an object in Multiplayer
ConPrice posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi everyone! ( This is a repost, because I have some debug and video demo) I have a problem. I have been trying to create a script that will let me spin/rotate an object real fast. The object in question is LightHouse (tall) (Land_LightHouse_F). But I had one problem. the lighthouse's pivot point is at its door, not at its centre. So I have been using this code. Which got rid of the problem of lighthouse spinning around its door instead of its centre: params ["_objectToSpin", "_spinSpeedMin", "_spinSpeedMax", "_timeToReachMaxSpeed"]; // Initialize parameters _spinSpeedMin = _spinSpeedMin; // Initial rotation speed in degrees per second _spinSpeedMax = _spinSpeedMax; // Maximum rotation speed in degrees per second _timeToReachMaxSpeed = _timeToReachMaxSpeed; // Time to reach maximum speed in seconds // Get the initial position of the object _initialPosition = position _objectToSpin; // Ensure the object is initially on the ground _initialPosition set [2, (_initialPosition select 2) + 0.1]; _objectToSpin setPos _initialPosition; // Calculate model's center offset (adjust these values based on your model's pivot) _modelCenter = [0, 0, 0]; // Replace with the actual offset if known // Initialize rotation and time _lastTime = diag_tickTime; _startTime = _lastTime; // Record the start time _initialHeight = (_initialPosition select 2); _currentRotationSpeed = _spinSpeedMin; // Initial rotation speed // Main loop to handle rotation while {alive _objectToSpin} do { _currentTime = diag_tickTime; _deltaTime = _currentTime - _lastTime; // Calculate elapsed time since start _elapsedTime = _currentTime - _startTime; // Calculate current rotation speed based on elapsed time if (_elapsedTime < _timeToReachMaxSpeed) then { _currentRotationSpeed = _spinSpeedMin + (_spinSpeedMax - _spinSpeedMin) * (_elapsedTime / _timeToReachMaxSpeed); } else { _currentRotationSpeed = _spinSpeedMax; }; // Calculate new rotation angle _rotationIncrement = _currentRotationSpeed * _deltaTime; _currentDir = getDir _objectToSpin; _newDir = _currentDir + _rotationIncrement; _newDir = _newDir % 360; // Ensure the angle stays within 0-360 degrees // Calculate the current position _currentPos = position _objectToSpin; _newPos = [ (_currentPos select 0) - (_modelCenter select 0), (_currentPos select 1) - (_modelCenter select 1), _initialHeight // Maintain consistent height ]; // Apply rotation _objectToSpin setDir _newDir; // Set the new position _objectToSpin setPos [_newPos select 0, _newPos select 1, _newPos select 2]; _lastTime = _currentTime; // Update the last time // Sleep to yield to other processes sleep 0.01; }; This script was working fine until I tested it on a dedicated server. On a dedicated server lighthouse spins around its door instead of its centre. I am not good at math, so most of the code is just bits and pieces I got from the internet and put together. I call the script this way: I have an object with addAction: this addaction["Spin it", { [_this select 0,_this select 2] remoteExec ["removeAction", 0, true]; null = [] execVM "scripts\end.sqf"; }, [], 6, false, true, "", "", 5]; and end.sqf has the line: null = [object_to_levitate, 0, 120, 20] execVM "scripts\spin.sqf"; at the top. I don't know how to solve this issue. I appreciate any help. Video demonstration of what is happening instead of what is supposed to happen: I run the code with debug messages: Singleplayer: Current position : [8684.5,10613.9,0.1], New position after adjustment: [8684.5,10613.9,0.1] Object rotated to NewDir = 284.013 and moved to NewPos = [8684.5,10613.9,0.1] and position numbers never change. They stay the same. Only things that change are direction, rotations speed/increment and elapsed time. And this is the result when I run this mission on multiplayer server: Current position : [8683.16,10611.3,0.1], New position after adjustment: [8683.16,10611.3,0.1] Object rotated to NewDir = 324.629 and moved to NewPos = [8683.14,10611.2,0.1] Notice the difference between position numbers? And positions numbers constantly change unlike single player where they would stay constant. -
Hi everyone! I am making a dynamic AI vs AI king of the hill mission and I can't get the AI to capture the sector after it has been moved with setPos. I have programmed parameters to choose the size and location of the target area "sectorModule_F (TA_1)" . Everything is working as intended , script side. However, the spawned groups from the spawn AI modules don't move towards TA_1's new pos. They instead move towards TA_1's original editor placed position. I use setPos and setVariable "pos" to change TA_1's location. this is what I add to the sector modules init filed. This changes the zone size and location to one of 3 test positions. These test positions are logic markers placed in the editor. The zone changes size and location as intended. Players can cap the zone as normal. I need help with understanding the init order of the modules. It seems to me that the sectors location data is stored as a variable in one or more of the 4 sector control modules, as the mission initializes. However, I can't identify the specific variable outside the sectorModule_F that stores the area position so that I can change it with setVariable and make the spawned AI move towards the new sector Pos. Please help me. I used "allVariables" command on the 4 module types that are present in the editor: ModuleMPTypeSectorControl_F, SectorModule_F, ModuleSpawnAI_F, & ModuleSpawnAISectorTactic_F. Please, If anyone who is familiar with these modules and their variables could give me some advice and maybe even a solution I would really appreciate it. Thank you.
- 2 replies
-
- setpos
- sectormodule_f
-
(and 4 more)
Tagged with:
-
Guys I need help with setting position of object follownig array of coordinates but including negative Z. https://forums.bohemia.net/forums/topic/153382-shk_pos/ I found this but links are broken and found this ; _mystartpositions = [[0,0,0],[5234,7345,0]]; _rndstartposition = _mystartpositions call BIS_fnc_selectRandom; object1 setpos _rndstartposition; but code only place object on those two locations randomly. Eden placement radius is useless because it always place object on surface. I need this: -moored naval mine to be randomly placed in specific area on the sea (could be marker) but also to randomize depth (z axis). For now, I only manage to place mine randomly X and Y but Z is always the same distance from the bottom so divers alsway know to dont search for mine between surface and bottom -40m. (40m is a chain of naval mine which is always placed on bottom.) - That is what I need! Z randomized axis so the mine could be on any depth between bottom and surface. Thanks in advance
-
Client moving a Helipad placed using the Eden Editor (Server) via remoteExec
LSValmont posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello guys. I need your help once again. I have this line of code working perfectly for the Server Host: openMap true; MapClicked = false; onMapSingleClick "HHH setPos [_pos select 0,_pos select 1, 0] ;(group transportHeli) move _pos; MapClicked = true; onMapSingleClick ''; true;"; Where HHH is the name of a Helipad placed on the Eden Editor. That previous line does not work in MP of course since when a client calls the script the helicopter with crew (also placed via Editor) nor the Helipad move to the onMapSingleClick location. I've tried the following remoteExec code: onMapSingleClick "[HHH,[_pos select 0,_pos select 1, 0]] remoteExec ["setPos", HHH]; [(group transportHeli),[_pos]] remoteExec ["move", (group transportHeli)]; MapClicked = true; onMapSingleClick ''; true;"; But I get this error: Error SETPOS: TYPE ANY , EXPECTED OBJECT. If I remove: "[HHH,[_pos select 0,_pos select 1, 0]] remoteExec ["setPos", HHH]; And just leave: [(group transportHeli),[_pos]] remoteExec ["move", (group transportHeli)]; Then the error is: Error MOVE: TYPE ANY , EXPECTED OBJECT. But I double checked and the location of both the SetPos and Move commands on the remoteExec are in the correct location and should be working... BIS BUG? Any ideas on how I can solve this issue and/or any other method to get the client to move the server placed helicopter on command? Thanks in advanced.- 3 replies
-
- setpos
- remoteexec
-
(and 2 more)
Tagged with:
-
Teleporting via user action (SOLVED)
WurschtBanane posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi again, i want to create a user action on an object that will teleport the person activating it to a marker called marker_Nimitz. I have read about player setpos xxx but i am pretty sure this will not work in multiplayer with JIPing units. -
SetPos behaving differently on a dedicated server?
simkas posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
I've noticed some really odd behavior when using setPos/setPosASL on a dedicated server. If I'm testing things locally, I can do setPos on a unit in any state and it will always work with no problems. On a dedicated server, it only appears to work if a unit is standing on the ground and is not in a vehicle. If they're in a vehicle or they're falling in mid-air, setPos does absolutely nothing. It doesn't seem to be a locality issue, as running it globally or remoteExec'ing it on the unit seems to make no different, setPos just seems to behave differently when on a dedicated server. Is this a bug or is there something with how that command works that causes this? -
player setpos vehicle / player moveInCargo after respawn not working
LoOni3r posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
hi, I want the player to be teleported to a MHQ. I'm hereby doing this: if (!isEngineOn westmhq1) then { player moveInCargo westmhq1; }else{ player setPos (westmhq1 getPos [10,10]); }; if (!isEngineOn westmhq1) then { player moveInCargo westmhq1; }else{ player setPos (westmhq1 getPos [10,10]); }; that works too. If the MHQ named westmhq1 is destroyed, spawns it again: _vehicle = _this select 0; _respawntime = _this select 1; _facingofvehicle = getDir _vehicle; _positionofvehicle = getPosATL _vehicle; _vehicletype = typeOf _vehicle; _name = vehicleVarName _vehicle; .... _vehicle = _vehicletype createVehicle _positionofvehicle; _vehicle setVehicleVarName _name; _vehicle setPosATL _positionofvehicle; _vehicle setDir _facingofvehicle; ... that works too. After respawning from westmhq1, the player is no longer teleported. No error message appears. Unfortunately, I do not understand why that is. Maybe someone can explain why the player is no longer teleported after respawn westmhq1. thanks..- 11 replies
-
- setpos
- moveincargo
- (and 4 more)
-
Hello armaholics! I've run into some trouble with AI and a certain building. I've put AI Waypoint to go into to a military cargo building. The problem is not if they can go inside. The group leader goes where he's suppose to, but some other group members start crawling under the building, then standing up. This results the AI half under and half inside the building. Link to image of the building Is there a way to disable AI from crawling? Forcing them to not go under the building. I'm aware of putting AI to only stand or only crouch, but I want them to be able to crouch and stand. Just removing the crawling aspect. Thanks in advance! Some of my missions: [CO-04] Last Stand - Compound [CO-04] Last Stand - Town [CO-04] Terrorist Hunt - Village [CO-04] Terrorist Hunt - Factory
- 8 replies
-
- disable ai
- crawl
-
(and 2 more)
Tagged with:
-
All, I'm trying to set the altitude of a pipe (class is Land_IndPipe1_20m_F). The pipe is oriented to terrain normal. The issue is that the pipe's inclination gets completely messed up. This is the pipe in the editor: This is the pipe after setting its altitude from a script: Things I've tried: _currentPipe setPos [getPos _currentPipe select 0, getPos _currentPipe select 1, _altitude]; _currentPipe setPos (_currentPipe modelToWorld [0, 0, _altitude]); _currentPipe setPosATL (_currentPipe modelToWorld [0, 0, _altitude]); _currentPipe setPosATL [getPosATL _currentPipe select 0, getPosATL _currentPipe select 1, (getPosATL _currentPipe select 2) + _altitude]; _currentPipe setPosASL [getPosASL _currentPipe select 0, getPosASL _currentPipe select 1, (getPosASL _currentPipe select 2) - _altitude]; To no avail. ...Any ideas? Thank you, _SCAR
-
Needing help with setting an objects position
CreativeProduct posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
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 ~ -
Hello, I've been trying to create a shoothouse for my community but I've run into a very strange problem. Attached below is the mission file. I've made a collection of scripts to create a CQB enviroment with randomized entry point and random target placement. Works fine in SP (so logic is a-ok) but I've tried to test it in a non-dedicated server and alas not only the doors are not inmediately moved, but the targets are sometimes not moved at all; actually, the targets are moved in the host machine just fine, but the other player only sees the target in the new position once the host has shot it or after some random delay. Currently the scripts are triggered via addAction, which executes via execVM, scripts that change the position and direction of the objects syncronized. As I said, the logic works as intended in SP, and for whoever is Server when in coop, but the other players experience the aforementioned delay in object movement. As far I've understood it, effects of setPos are global and broadcasted so if my script only makes use of that command (and setDir), why is it experiencing this delay? You can download the mission here. Any help would be appreciated. And, thanks for reading! These scripts may be used in part or completely only when due credit is given.
- 4 replies
-
- Multiplayer
- setPos
-
(and 1 more)
Tagged with: