Jump to content
Sign in to follow this  
Daemios

Referencing one object to place another issue

Recommended Posts

I'm having a heck of a time trying to figure out a problem I'm having. I'm working on a script that spawns a group of objects into a base. I'm using a single object to create the "center point" so to speak, like so:

_placePos = (getpos bluAlphaMain);

I then use something like:

bluAlphaEnterTower = "Land_Cargo_Patrol_V2_F" createVehicle (_placePos);
bluAlphaEnterTower setPos [((_placePos select 0)-2),((_placePos select 1)-30),0];

Now, I realize that the second line there is redundant because I can do that in the spawn, but this allows me to use the debug window to place objects rapidly and edit them into proper position.

My problem is when I use something like that to spawn an object, it will place it at a nearby-but-not-perfect position. This is especially apparent if I want to spawn objects that look "attached" to a building, like solar panels.

Here is a perfect example of a few scripts that seem like they should work but for some reason don't. Keep in mind that if I copy the code directly from the script and run it in the debug window they are placed exactly where I want them.

"Main" Script:

// Generate Spawn
_marker = createMarker ["respawn_east", (getPos op_hq_tower)];
sleep 0.1;

// Hold position to spawn cleanly
_placePos = (getPos op_hq_tower);

// Cleaup Box
deletevehicle op_hq_tower;

// Create the Building
op_hq_tower = "Land_Cargo_Tower_V3_F" createVehicle (_placePos);
op_hq_tower allowDamage false;

_units = [] execVM "hq\opfor\structures\tower\units\units.sqf";

Then the "units" script:

_placePos = (getPos op_hq_tower);

op_hq_solarArray1 = "Land_SolarPanel_1_F" createVehicle (_placePos);
op_hq_solarArray1 setPos [((_placePos select 0)+3.5),((_placePos select 1)-6.55),((_placePos select 2)+16.5)]; 
op_hq_solarArray1 setDir 180;

op_hq_solarArray2 = "Land_SolarPanel_1_F" createVehicle (_placePos);
op_hq_solarArray2 setPos [((_placePos select 0)-3.25),((_placePos select 1)-8.7),((_placePos select 2)+16.5)];    
op_hq_solarArray2 setDir 180;

The end result ends up looking like this - http://i.imgur.com/Tz6kTdl.jpg

Am I going about this all wrong? What's the problem here?

Share this post


Link to post
Share on other sites

https://community.bistudio.com/wiki/createVehicle_array

Look at the fifth parameter.

What you want there is "CAN_COLLIDE", that stops arma from automatically moving the newly created Object to a free position.

Oh and for what you're doing there, this command might interest you aswell:

https://community.bistudio.com/wiki/modelToWorld

Using this you can place Objects with an offset to your origin-object. With a bit of extra code you can also make the whole setup rotateable.

Share this post


Link to post
Share on other sites

Ok, I spoke to soon.

I changed the code to:

	op_hq_solarArray1 = createVehicle ["Land_SolarPanel_1_F",[((_placePos select 0)+3.5),((_placePos select 1)-6.55),((_placePos select 2)+16.5)],[], 0, "CAN_COLLIDE"];
op_hq_solarArray1 setDir 180;

And it still clips into the wall. What am I doing wrong?

Edit: Again, http://i.imgur.com/BZnvGr7.jpg is what it should look like. http://i.imgur.com/Tz6kTdl.jpg is what spawns. I can achieve the first picture by simply typing:

_placePos = (getpos op_hq_tower); 
op_hq_solarArray1 setPos [((_placePos select 0)+3.5),((_placePos select 1)-6.55),((_placePos select 2)+16.5)];

into the console. Not understanding why it doesn't want to spawn properly.

Edit 2: Honestly it feels like there's some sort of improper reference somehow, but I tried sleeping to make sure the object was fully "there" just in case, and that didn't work. I don't understand how the script can do the exact same thing that I do in console and come up with a different result.

Edited by Daemios

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×