Author Topic: Freezing an Object.  (Read 1262 times)

How would I go about making an item so that it can be frozen and then unfrozen, so if it was in mid-air it wouldn't fall. The only way I can think of doing this is making a static object of that object but then if it's a vehicle it looses it's wheels and whatnot.

Hacky method: Repeated schedule setTransform'ing it to whatever position it was when frozen. Use something like the ArrayStackSO + tick functions to use one schedule for every frozen object.

Hacky method: Repeated schedule setTransform'ing it to whatever position it was when frozen. Use something like the ArrayStackSO + tick functions to use one schedule for every frozen object.

I though about using script Objects but I was too scared =D, I'll have a go.

I try to avoid doing stuff like this because constant loops have really bad effects on servers (like the gravity guns).

Having lots of schedules running in parallel does cause lag, but using one 'controller' with a single running schedule causes much less lag. Compare the Trap Bricks with six to eight arrow traps to the Event Bricks with the same - Traps uses one schedule every 500 or so ms for each object, Events uses one schedule every 100ms (10ms on my testing copy) and a massive for loop in the scheduled function but still has no lag to me.

if you are going to repeatedly settransform() on a vehicle or whatever, it would be a good idea to setvelocity("0 0 0") as well, otherwise the constant force of gravity will keep increasing its downward velocity and it will get increasingly glitchy-looking.

See the gravity gun with companion cube mod. Spawn two companion cubes, stack them, then move the first one from under the second. If you can figure out why the second stays there, you'll be able to freeze objects.

See the gravity gun with companion cube mod. Spawn two companion cubes, stack them, then move the first one from under the second. If you can figure out why the second stays there, you'll be able to freeze objects.
Well thats just a physics glitch.

Well, the cube doesn't have a control object.  If you wanted to do something similar with a player, you'd have to remove its control object (not recommended).

Note: I said that as a joke.

Seriously, I'm not too sure how you could go about freezing an object without setting some laggy loop to keep it from moving.

Didnt rtb do this?
Code: [Select]

function serverCmdFreezeMe(%client)
{
if($pref::server::copsandrobbers || %client.sitting)
{
return;
}

if(%client.frozen == 0)
{
%client.frozen = 1;
%client.freezeObject = new StaticShape()
{
      position = %client.player.getTransform();
      rotation = "1 0 0 0";
      scale = "0.001 0.001 0.001";
dataBlock = "flowers";
      };
%client.freezeObject.setcloaked(true);
%client.freezeObject.MountObject(%client.player,1);
}
else
{
%client.frozen = 0;
%client.freezeObject.unMountObject(%client.player);
%client.freezeObject.delete();
}
}

Or by mounting to an object that can't move. Yeah.