Jump to content
Sign in to follow this  
wyattwic

Prevent an object from moving

Recommended Posts

Hello everyone!

I need to prevent an ammunition crate from moving, however if I were to disable simulation, it disables inventory as well (unacceptable in this case).

Is there another way to fix a object in space without disabling simulation?

Share this post


Link to post
Share on other sites

Hm, you could try to get it's position and move it back there all the time, not tested ingame but should work:

null = [this] spawn {_crate = (_this select 0); _pos = (position _crate); while {alive crate} do {sleep 1; _crate setpos (getpos _pos)}}

This will store there crate's initial position and set it back there every second, you can of course decrease the time the script sleeps but this equals less performance.

Cheers! :)

Share this post


Link to post
Share on other sites

A more elegant solution would be to create a helper object, hide it and then attach the crate to the helper object.

Share this post


Link to post
Share on other sites

Place a logic an the map an put in its init line:

crate attachto [this,[0,0,0]];

Under circumstances you have to experiment with the height (the last numerical).

Share this post


Link to post
Share on other sites
Place a logic an the map an put in its init line:

crate attachto [this,[0,0,0]];

Under circumstances you have to experiment with the height (the last numerical).

To avoid having to experiment, simply don't put the 2nd argument. So it'll just be [this]. As well, I suggest placing the crate where you want it and having that code in the init of anything, as long as 'this' is changed to the gamelogic's name, and crate or something else is the crate's name. That way you can place the crate, not the GL. Also, note that attaching it will set the direction to the getDir of the object you're attaching to. So you'll want to setDir the game logic before attaching.

Here's how I did this for a mobile respawn:

if (G_Moveable_Mobile == 0) then {
_hp = "Land_HelipadEmpty_F" createVehicle (getPos _mobile);
_hp setDir (getDir _mobile);
_mobile attachTo [_hp];
};

Obviously, I used an invisible helipad instead of a game logic. Either works.

Share this post


Link to post
Share on other sites

Grumpies solution appears to work the best, no guessing involved. Placed a invisible helipad where the crate needed to be originally, then used attach to to provide the elevation needed. Due to a custom floor the crate has to be 0.01 above ground level or else it would glitch and fly away, as well as explode/die.

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  

×