Calling BIS_fnc_inTrigger resizes the input position array from 3 to 2.
Description
Description
Details
Details
- Legacy ID
- 191334004
- Severity
- None
- Resolution
- Open
- Reproducibility
- Always
- Category
- Scripting
Steps To Reproduce
- Open Editor on VR map
- Place a standard trigger away from the player and name it "testTrigger"
- Place rifleman player unit on map
- Once in-game as player in the debug console input: "tPos = [0,0,0]; tPos2 = tPos; tReturn = [testTrigger, tPos] call BIS_fnc_inTrigger;"
- Add watches for the tPos and tPos2 variables, I expect tPos and tPos2 to equal [0,0,0] after executing this code
- Execute the code
- You'll see tPos and tPos2 are not equal to [0,0,0] as the use of the resize command has changed tPos and tPos2 to [0,0]
Event Timeline
Comment Actions
This appears to be because the BIS_fnc_inTrigger function utilizes the resize command which seems to be modifying all references to the array instead of making a copy and changing just that one variable.
If I execute this code: tPos = [0,0,0]; tPos2 = tPos; tPos resize 2;
I would expect tPos to equal [0,0] but I do not expect tPos2 to equal [0,0] as well.
Comment Actions
A temporary fix for this is to make a copy of the array when setting tPos2.
Example: tPos = [0,0,0]; tPos2 = +tPos; tPos resize 2;
In the above example tPos is [0,0] and tPos2 is [0,0,0] which is what I expected from the examples above.
This behavior also happens with any engine commands that modify an array by reference.