Jump to content
syrasia

[SOLVED] WeaponHolderSimulated not falling?

Recommended Posts

Hey there,

 

I have seached the forums and done a lot of testing, but I can't seem to get my WeaponHolderSimulated to fall down. If flaots in air where i place it.

Here the script to it:

params ["_object"];
// TODO: Objekte verteilt auf dem Boden lagern, vielleicht auch die "Annahme" verweigern, bei zu vielen Objekten
private _inFrontOfPlayer = player modelToWorld [0, 1, 1]; // position infront des Spielers
private _holder = createVehicle ["WeaponHolderSimulated", [0, 0, 0], [], 0, "CAN_COLLIDE"]; // "Objekt-Halter" erstellen
// GroundWeaponHolder groundWeaponSimulated

// alle Objekte vor dem Spieler, müssen vieleicht noch Postionanspassen oder bei Platz sogar ablenen!
//private _holderList = nearestObjects [_inFrontOfPlayer, ["GroundWeaponHolder"], 1, true];

_holder addWeaponCargoGlobal [_object, 1];

_holder setPos _inFrontOfPlayer; // Position korigieren

true

And here a screenshot of my "problem":

 

51BF7B4B7341EE96FF5E472FA22E11A91DAD15B3

 

What am I missing?

Share this post


Link to post
Share on other sites
4 hours ago, syrasia said:

 

What am I missing?

 

From memory, nothing. I don't think they have any physx. Either setPos them onto the ground, or maybe attach them to something affected by gravity, like a can of food. 

Share this post


Link to post
Share on other sites

Hello there syrasia !

 

Just use :

ex:

_pos = getPosASL player;
_Loot = createVehicle ["WeaponHolderSimulated",[_pos select 0, _pos select 1,_pos select 2], [], 0, "CAN_COLLIDE"];

 

You can also take a look here if you like :

 

 

Share this post


Link to post
Share on other sites
16 hours ago, syrasia said:

And here a screenshot of my "problem"

Why don't you just spawn it on the ground? Instead of spawning it in the sky and trying to letting it fall, tons of simulated weaponHolders might cause performance issues.

 

10 hours ago, GEORGE FLOROS GR said:

Just use :

ex:

No that's wrong. createVehicle takes PositionATL, not ASL.

  • Like 1

Share this post


Link to post
Share on other sites
On 10/14/2019 at 9:42 PM, beno_83au said:

 

From memory, nothing. I don't think they have any physx. Either setPos them onto the ground, or maybe attach them to something affected by gravity, like a can of food. 

WeaponHolderSimulated should have physx from what I read. But well, I don't see it in my case tho. 😅

 

On 10/14/2019 at 10:39 PM, killzone_kid said:

Try WeaponHolderSimulated_Scripted

Same result.

 

23 hours ago, Dedmen said:

Why don't you just spawn it on the ground? Instead of spawning it in the sky and trying to letting it fall, tons of simulated weaponHolders might cause performance issues.

Have done, but clipping is a issue. Well looks like I have to work with it, even if i dont like it.

 

Here what can happen with "GroundWeaponHolder" and placing it on the ground (using: modelToWorld [0,1,0]): (As the other Holders don't fall in my case, they behave the same, just a side note.)

F2A811CFC6FC0B2A7750686C4FB1FCF45A68366D

My hope was to solve those sometimes clipping issues (was standing on the stairs while "placing" the object.

Point is, here it is "just" a weird spot, while many other times it got unreachable and therefore problematic.

 

Edit:

Just found out a thing: I am taking the player pos and shifting it 1 to the front, obvious it clips into stuff. 😓

Is it possible to get the "above ground" of that pos simply?

I will do some experiments, but atm I can easily let things disappear standing in front of elevated objects (like the ledge of a building or even low rocks).

 

Edit 2:

I found a passable solution for myself.

Changed the "position setting part" to this:

_holder setPos _inFrontOfPlayer; // Position korigieren
private _zCorrection = -(getpos _holder select 2);
systemChat str(_zCorrection);
if (_zCorrection < -0.1 or _zCorrection > 1.5) then {
	hint "high distance";
	_result = false;
	deleteVehicle _holder;
};
_inFrontOfPlayer set[2, (_inFrontOfPlayer select 2) + _zCorrection];
systemChat str(_inFrontOfPlayer vectorDistance getPos player);
_holder setPos _inFrontOfPlayer;

_result

It places the holder in most cases correctly on the surface of an object and in cases it would be placed "to far" (like under the stairs) it blocks the placement.

I was experimenting also with "vectorDistance" (as one can see in my "systemChat" speed debug/testing), but it was not really reliable for my purpose, giving many false alarms, while in other cases I could "place" objects under buildings while standing of said those, as the returned distance was low (my threshold was 1.5).

Stairs are still not optimal, as they still get placed beneath, but only if you stand in front of them or just slightly standing on them, else my test blocks it. Not perfect, but good enough for me.

 

If someone has a better or cleaner solution, I would appreciate for sharing it.

 

And thanks for the Help so far!

Share this post


Link to post
Share on other sites
3 hours ago, syrasia said:

My hope was to solve those sometimes clipping issues (was standing on the stairs while "placing" the object.

Make a lineIntersectsSurfaces on GEO LOD, from your players feet (or better knees) to the wanted target location.
If you hit a wall on the way, then place it between player and that wall.

On stairs it will probably just place it at the players feet, which is fine I assume?

 

3 hours ago, syrasia said:

Is it possible to get the "above ground" of that pos simply?

Make a lineIntersects from, maybe 20m above, downwards. First hit will be topmost plane.

  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, Dedmen said:

Make a lineIntersectsSurfaces on GEO LOD, from your players feet (or better knees) to the wanted target location.
If you hit a wall on the way, then place it between player and that wall.

On stairs it will probably just place it at the players feet, which is fine I assume?

 

Make a lineIntersects from, maybe 20m above, downwards. First hit will be topmost plane.

The lineIntersectsSurfaces looks really promising. will try that one out.

 

But the "first surface" is not always right, as the player can be in buildings and the roof is the first surface. So therefore I think it is necessary to start from the player position/height.

I will play around with the new knowledge and as I got very close to promising solution, so I call this solved now. I think I can figure the last bits on my own.

 

Thanks for the help!

  • Like 1

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

×