Jump to content

Recommended Posts

Hi there.
So I've been trying to make a script that drops an object on a players head. I need it to be able to work even if the player is standing in a building. The two commands that are supposed to disable collisions are `enableSimulation false` and `disableCollisionsWith`. `disableCollisionsWith` would be harder to implement considering it would have to detect any possible map and mission placed object. And, unfortunately, even though I set Enable Simulation to false for the dropped object, if I am standing under a roof or another object, the obstructing object is destroyed (sometimes exploding) when the falling object lands. 

player switchMove "HubSpectator_stand";
_unit = player;
[] spawn {
	_cTime = time;
	_pos = position player;
	_typeObj = selectRandom ["Land_FieldToilet_F","Land_ToiletBox_F"];
	_fallObj = createVehicle [_typeObj, [_pos select 0,_pos select 1,(_pos select 2) + 10], [], 0, "CAN_COLLIDE"];
	_fallObj enableSimulationGlobal false;
	_fallObj allowDamage false;
	while {(getPosATL _fallObj) select 2 > 0.01} do {
		sleep 0.01;
		_fallObj setPosATL [_pos select 0,_pos select 1,((getPosATL _fallObj) select 2) - 0.2];
		if (time - _cTime == 5) exitWith {};
	};
	sleep 5; 
	deleteVehicle _fallObj;
};
sleep 1;
player setDamage 1.5;
player switchMove "";
sleep 5;
hideBody _unit;

I have tried the non-global `enableSimulation`, as well as `while {!simulationEnabled _fallObj} do` loops.
Anyone have any idea how to go about this?

Edited by PortalGunner

Share this post


Link to post
Share on other sites

You want to keep simulation on for this. 

 

1. Cast a ray from where you drop the thing to where your player is. Use lineIntersectsSurfaces for this. 

2. Get all parent objects from the raycast result 

3. Disable collisions with each object by using disableCollisionWith

  • Thanks 1

Share this post


Link to post
Share on other sites

Curry's suggestion is good.  Another option is to cast a ray from unit's head straight up, and drop the object from below the first intersection, or from your desired height if there is nothing directly over unit's head.

Share this post


Link to post
Share on other sites
On 5/16/2019 at 7:56 PM, mrcurry said:

You want to keep simulation on for this. 

 

1. Cast a ray from where you drop the thing to where your player is. Use lineIntersectsSurfaces for this. 

2. Get all parent objects from the raycast result 

3. Disable collisions with each object by using disableCollisionWith

Unfortunately disableCollisionWith is not intended for use between two world objects, regardless of it's description. 
 

Also as far as I know, lineIntersectsSurfaces will only detect objects underneath the direct centre of the source, so if the object was big enough and you were standing, say, next to but not under a building, it would not detect it.

 

EnableSimulation confuses me because in several places it says it disables collision - yet that doesn't seem to be the case in this script. I can't even find anything explicitly saying it doesn't disable collision. 
This whole situation is weirding me out.

Share this post


Link to post
Share on other sites
On 5/17/2019 at 2:37 PM, PortalGunner said:

Unfortunately disableCollisionWith is not intended for use between two world objects, regardless of it's description. 

I'll have a look into this, AFAIK it should work as advertised but I have limited experience with the command myself. I'll get back to you on that. 

 

On 5/17/2019 at 2:37 PM, PortalGunner said:

Also as far as I know, lineIntersectsSurfaces will only detect objects underneath the direct centre of the source, so if the object was big enough and you were standing, say, next to but not under a building, it would not detect it.

Get the corners of the falling object's bounding square in the XY-plane and do a raycast at each corner + the center.

For better accuracy you can also use the midpoint of each side of the square.

Append all results and disable collision respectively. 

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

×