Jump to content
Sign in to follow this  
Tankbuster

Problem with spawning objects on zargabad pavements

Recommended Posts

I'm spawning objects in Zargabad for the test mission in my IED kit.

The script finds the road edge, then places street clutter objects there and under them, an IED.

But in Zargabad, the pavement (for American users, read "sidewalk") causes problems.

isOnRoad works reasonably well. Here you can see how I'm placing, at 1m intervals spheres on road and arrows off road. This is one of the divided roads in Zargabad. Other than the intersections where the central reservation is said to not be road where I'd hope it was, it's all going fine so far.

O0RJ5.jpg

But look here; Where the pavement is between the buildings and the road, spawned objects are sunk into the pavement. Inside the building, however, they are back up where you'd expect them. I'm assuming that where they spawn on pavement, they are actually on the underlying terrain?

kSWfh.jpg

It's even worse at, for example, the war memorial object where the arrows are completely covered by the steps.

ZNpEd.jpg

Note that I have to use "CAN_COLLIDE" in the createvehicle. If I don't objects that are deemed to be on the road get shunted off it, objects that are deemed to be on it, are shunted off it and anyway, it doesn't solve the "sunken into pavement paving slabs problem" I describe above. See below, there are spheres offroad and arrows on it. Ugh.

8SSLf.jpg

So, my question, or at least the first of more on this subject is, how can I get the objects that happen to spawn on the pavement to actually spawn on the upper "skin" on the pavement, not on the terrain under it?

Share this post


Link to post
Share on other sites

It looked like a quite interesting and challenging task so I decided to check it out. After my tests, I'm not sure if it can be properly done with current ArmA scripting possibilities.

My first guess was to use lineIntersectsWith to check if there are objects in the way and then adjust height by doing few cycles of lineIntersects checks (yet pretty heavy but if you pre-calculate it its okay) but it doesn't seem to work with pavements (tested on Chernarus, might be different on Takistan), they never appear resulting array and never detected.

My test code:

_pos1 = getPosASL player;
_pos2 = +_pos1;
_pos1 set [2, (_pos1 select 2) + 5];
_pos2 set [2, (_pos2 select 2) - 1];
hint format ["%1", lineIntersectsWith [_pos1, _pos2, player]];

Checks for objects in 10 meters line (5 above and 5 below the player)

Pavements ARE objects thought but unfortunately they don't have class name to fine them so its only possible to use result of str(object) which looks like "187047: sidewalkclearlong.p3d" for Chernarus pavement. There is a still a way to solve the problem though, a very weird and not efficient one: Since we can't check if object returned by nearestObjects is pavement or not by checking its class, we can try to compare model name symbol by symbol and if it matches say "sidewalkclearlong.p3d" or other pavement objects model names then its a pavement. Later we get pavement's boundingBox and find 4 top points coordinates with modelToWorld which we can use to calculate pavement's elevation about the ground and adjust your object's coordinates accordingly.

UPD: Above applies only to simple flat pavements.

Sorry if I wasn't to clear in some of my ideas due to my English, let me know if this helped you a bit.

---------- Post added at 18:58 ---------- Previous post was at 18:08 ----------

Speaking of first method here is script that I made. Caution, its a rough draft and not optimized or commented at all:

{deleteVehicle _x} forEach objs;
objs = [];

_d = 8;
_step = 0.3;
_ppos = getPosATL player;
_hsteps = 100;

player sideChat "Start";
for "_i" from (_d * -1) to _d do {
for "_j" from (_d * -1) to _d do {
	_pos = +_ppos;
	_pos set [0, (_pos select 0) + _i * _step];
	_pos set [1, (_pos select 1) + _j * _step];

	_aslp1 = ATLtoASL(_pos);
	_result_pos = +_aslp1;
	_aslp1 set [2, (_aslp1 select 2) + 2 - 0.1];
	_aslp2 = +_aslp1;

	for "_k" from 1 to _hsteps do {
		_aslp2 set [2, (_aslp2 select 2) - (2 / _hsteps)];
		if(lineIntersects[_aslp1, _aslp2]) exitWith {_result_pos = _aslp2; _k = 9001;};
	};

	_o = createVehicle ["Sign_arrow_down_EP1", _result_pos, [], 0, "CAN_COLLIDE"];
	_o setPosASL _result_pos;
	_o setDir 0;
	objs = objs + [_o];
};
};
player sideChat "Done";

Result:

RmIhwl.jpg

But as I mentioned it doesn't work with pavements since they are not detected by lineIntersects for some reason.

Edited by SaMatra

Share this post


Link to post
Share on other sites

Samatra,

That's very interesting. Thanks. :)

I understood what you suggest using lineintersects and I can see what you're doing with the code. The arrows go over the car nicely, but at the bottom left of the screen, they are sunk into the pavement.

I'm experimenting with spawning an object that has full physics, such as a civ. They seem to be spawned on top of the pavement skin, not on the underlying terrain.

qj7rc.jpg

If you can't read it, the getpos select 2 of the civ is 0.0014782 and the bucket is at 0.000583649. So perhaps we have the beginning of a solution.

---------- Post added at 22:15 ---------- Previous post was at 22:15 ----------

Note that these were spawn just in the mission editor, not by code or anything.

Share this post


Link to post
Share on other sites

Great idea! Trying to spawn objects with different simulation might be a way to solve the problem. Please post back here if you'll solve it. Thanks.

Share this post


Link to post
Share on other sites

It works with rabbits (instead of men) too. Though weirdly, the disableAI move only lasts for 20 seconds on the rabbit, before it runs off.

Share this post


Link to post
Share on other sites

As a suggestion, is there a way you can check if the arrow is intersecting with a piece of sidewalk? Then have it raised to a proper height? You can have an array in the script that checks if the arrow is intersecting with a certain object, then raise it to a proper level.

That's my level of understanding from what I've read so far, having the ability to check if it can collide would work, but since it seems that the sidewalk doesn't like that then maybe there is some FSM in one of the games PBOs that is able to detect this and properly place entities above the sidewalk.

Hope that helps a little

-Bigshot

Share this post


Link to post
Share on other sites

tempobj = createAgent ["Rabbit", [getPos bucket2 select 0, getPos bucket2 select 1] ,[], 0, "CAN_COLLIDE"];
bucket2 setpos getposATL tempobj;
deleteVehicle tempobj;

0z-V_GTz7ZA

It aint perfect. If you look closely, you can see the temporary rabbit as it is spawned and despawned very quickly. :)

The bucket pops up sure enough though. It jiggles about a bit and also, it's hovering a tiny bit, but I can always drag it down manually. I can't have these objects hovering - I spawn a hidden IED object under them, so this is vital.

Note also the other rabbit in the background from an earlier test. It has disableAI "MOVE" on it, but it still runs off after a time. We know a song about this don't we children? ( might only make sense to Brits of a certain age!)

---------- Post added at 23:43 ---------- Previous post was at 23:42 ----------

As a suggestion, is there a way you can check if the arrow is intersecting with a piece of sidewalk? Then have it raised to a proper height?

No, there isn't. That's what I'd hoped for.

Share this post


Link to post
Share on other sites

Great job figuring solution out Tankbuster. Thanks for the knowledge.

Share this post


Link to post
Share on other sites

Thanks for your help too. BSK as well. :)

---------- Post added at 00:18 ---------- Previous post was at 00:06 ----------

Just tested it when spawning the bucket on the road surface (ie not on pavement) to see if anything untoward happened. It didn't - the rabbit spawned and despawned - as far as I could tell the bucket started sitting on the ground and finished sitting on the ground unmoved, which is good.

---------- Post added at 01:01 ---------- Previous post was at 00:18 ----------

Oh dear. After such a good start...

I can't get rid of the hovering.

tempobj = createAgent ["Rabbit", [getPos bucket2 select 0, getPos bucket2 select 1] ,[], 0, "CAN_COLLIDE"];
bucket2 setpos [(getPosATL tempobj select 0), (getposATL tempobj select 1), ((getPosATL tempobj select 2) - 0.19)];
deleteVehicle tempobj;

The bucket seems to lift out of the ground much slower than I expected. I though it'd be instant, but it isn't

Also, no matter what I do with the select 2, the bucket is either hovering or still half buried. 0.2 or above it's half buried. Anything less and it hovers.

Such a shame, I thought I had this cracked. I means my IED system can't be used on towns with sidewalks. :(

Share this post


Link to post
Share on other sites

Simply create a logic above the ground, let's say 3m above the ground and let it "fall".

Then set the object with setPosATL to the ATL height of the logic.

Like for example:

0 spawn {
   logic = mylogicgroup createUnit ["Logic", [somepos select 0, somepos select 1, 3], [], 0, "CAN_COLLIDE"];
   waitUntil {(velocity logic) select 2 <= 0};
   myobject setPosATL (getPosATL logic);
};

(not tested but that's how it should work)

Xeno

Share this post


Link to post
Share on other sites

is the bucket a crucial part of the whole thing? i ask because it's one of the "static" objects in arma that has "real" physics and i'm sure that that's what's causing the hovering. i think the class it inherits from is called "thing". if the bucket isn't a must for the whole thing you should try some objects that don't have these properties. i'm not sure if that helps you in any way but maybe it does :)

Share this post


Link to post
Share on other sites
Simply create a logic above the ground, let's say 3m above the ground and let it "fall".

Then set the object with setPosATL to the ATL height of the logic.

Like for example:

0 spawn {
   logic = mylogicgroup createUnit ["Logic", [somepos select 0, somepos select 1, 3], [], 0, "CAN_COLLIDE"];
   waitUntil {(velocity logic) select 2 <= 0};
   myobject setPosATL (getPosATL logic);
};

(not tested but that's how it should work)

Xeno

Wow! A word from master himself. Thanks for sharing this technique!

Share this post


Link to post
Share on other sites

Thanks Xeno, tried it, the object still hovers just off the ground. :(

---------- Post added at 02:07 ---------- Previous post was at 02:05 ----------

is the bucket a crucial part of the whole thing? i ask because it's one of the "static" objects in arma that has "real" physics and i'm sure that that's what's causing the hovering. i think the class it inherits from is called "thing". if the bucket isn't a must for the whole thing you should try some objects that don't have these properties. i'm not sure if that helps you in any way but maybe it does :)

Yes, the bucket is crucial to the whole project. It's one of many street clutter objects that I spawn on the road side in order to hide IEDs. The bucket is a "small object" and is indeed class thing. In fact, all of the clutter objects are class thing.

The strange thing about all this is that if I put the bucket in the middle of the road, it sits on the road surface. The problem comes with the sidewalk sections. A normal spawn of the object sinks it into the sidewalk as you can see in the pics in post 1. Any method so far to lift the object to the surface skin of the sidewalk results in the hover you see in the videos.

Share this post


Link to post
Share on other sites

i was thinking about this the other day again and had an idea. try "object enablesimulation false" on the bucket. maybe it will disable the physical reaction to the object underneath. i didn't test it but it might work.

EDIT: just tried it in the editor and it works. it makes the bucket static. it should make it possible to place it more precise.

EDIT2:

http://i.cubeupload.com/3afXkj.jpg

as you can see you can place it very precise. it sinks a little bit into the front part of the sidewalk.

i hope you release this script! looks intresting:)

Edited by Bad Benson

Share this post


Link to post
Share on other sites

I don't usually do this but....

MOG!!!!!11

That's excellent, Benson. I really can't thank you enough. This script is brilliant In Zarga apart from this one problem which was a game stopper! It has the same effect on Chernarus too!

I'll try it this evening.

I used to use that command. Until recently, objects used to talk over the network all the time, even small ones so using this was a good way of saving some bandwidth, but it was fixed in a patch some time back so I stopped using it. I'll put it back in right away.

Thanks again, and thanks for the PM too. I had given up on this TBH. I reckoned if the likes of Xeno can't solve it, then it's probably insoluble. Until you rocked up. :)

Share this post


Link to post
Share on other sites

Yes, it works. That's so cool, and using it in conjunction with Xeno's logic idea works perfectly. :)

Share this post


Link to post
Share on other sites

awesome - more hunting in zarga to come - what a great community!

Share this post


Link to post
Share on other sites

Xeno,

Don't know if you're still reading this? Because your falling logic method does work when used with Benson's disable simulation trick. The good thing about it is that it works for both pavements and tarmac. So, a couple of followup questions.

Why do you use creategroup for the logic?

Should I delete the logic when I'm finished with it? (I'm making 20 -40 per town)

Thanks

Tanky -Paul-

Share this post


Link to post
Share on other sites

Holy Moly. It's done, at last.

Arrows denoting !isonroad are now on the top of the pavement objects.

4fHIW.jpg

Works across the road at the war memorial too, although there's other problems with it's geometry. Read spoiler for more.

Go prone at the base of the war memorial, then body roll into it.

GZp8g.jpg

Also, copes with objects on the map just fine too.

FWrmI.jpg

The problem is that the sidewalk object is missing some geometry. It's for a good reason though. If it had the missing LOD, tanks and vehicles would bounce when they touched it.

The solution is, as Xeno says, to create a logic (I used createAgent, not createUnit) in the air, wait for it to fall to the ground, then get it's posATL. Create your object there, then setPosATL it to the same location. This 'brute-forces' it into the right position. Then disable its simulation.

So, a huge thanks to Xeno and Benson for coming up with the solution and to Samatra and BigShotKing for having a damn good try. :)

Tanky

PS, you don't want to know about my FPS after the script that made all those globes and arrows over 2.5 square kilometers. :)

Edited by Tankbuster

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  

×