Aug 31, 2010, 2:15pm, mbgdemon wrote:Can you make a trigger that changes a marble physics property? (jumpimpulse, gravity etc) while your in it and goes back to normal when you exit? Just putting the lines doesn't work
About the same as above ok, a little longer, and damn I need to put this is my thread but not right now
Code:datablock TriggerData(FunkyPhysicsTrigger)
{
tickPeriodMS = 100;
};
function FunkyPhysicsTrigger::onEnterTrigger(%this,%trigger,%obj)
{
// Change Physics
defaultmarble.maxRollVelocity = 15;
defaultmarble.angularAcceleration = 75;
defaultmarble.brakingAcceleration = 30;
defaultmarble.gravity = 20;
defaultmarble.staticFriction = 1.1;
defaultmarble.kineticFriction = 0.7;
defaultmarble.bounceKineticFriction = 0.2;
defaultmarble.maxDotSlide = 0.5;
defaultmarble.bounceRestitution = 0.5;
defaultmarble.jumpImpulse = 7.5;
defaultmarble.maxForceRadius = 50;
}
function FunkyPhysicsTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
// Revert Physics
revertphysics();
}
function revertphysics()
{
defaultmarble.maxRollVelocity = 15;
defaultmarble.angularAcceleration = 75;
defaultmarble.brakingAcceleration = 30;
defaultmarble.gravity = 20;
defaultmarble.staticFriction = 1.1;
defaultmarble.kineticFriction = 0.7;
defaultmarble.bounceKineticFriction = 0.2;
defaultmarble.maxDotSlide = 0.5;
defaultmarble.bounceRestitution = 0.5;
defaultmarble.jumpImpulse = 7.5;
defaultmarble.maxForceRadius = 50;
}
The example above is for MBG, for MBP you need to sum up all marble names, from MarbleOne to MarbleFourty, there's also a name for when using a cutom marble, but I don't know it by heart (don't know where to look either).
So if you want to change a single physic, you need to put 80 lines, 40 to change and 40 to revert
In the above example no physics were changed so that'd be total useless code
Also, defined a new function revertphysics() that will set physics to normal, this is because you will need it again ahead.
You can leave out all the physics you do not want to change (you can leave them out in both enter and revertphysics). If you don't copy paste, be sure to add a semi colon ; behind the lines that require one (as demonstrated).
Also, I don't know what most of those properties do, but:
jumpImpulse = jumpImpulse, it's called impulse and not height because in lower gravity with same impulse you can go higher
maxRollVelocity = maximumspeed when not jumping, I don't know what it is in units but I would guess meters/sec (1 tile = 2 meters)
brakingAcceleration = I think how much speed the backwards key gives you, not sure, would prove for a fun tightrope level
bounceRestitution = knockback from hitting stuff, I think if you put this at 0.9 it would be like you have a super bounce on all the time
gravity = gravity ofc
To make a trigger behave like this, again, make a trigger of any kind in the LE (or however you would), give it a name so you can find it (you give it a name by filling in the field next to the Apply button). SAVE the level, go to the .mis and change Code:dataBlock = whatevertriggertypeyouused;
to
Code:dataBlock = FunkyPhysicsTrigger;
You will find the above in:
Code:new Trigger(NoJump) {
position = 3.14159 2.71828 6.62606;
rotation = 1 0 0 0;
scale = 6 6 6;
dataBlock = NoJumpTrigger;
polyhedron = 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000;
};
The above case was a NoJumpTrigger and it's name was NoJump (found between brackets next to new Trigger
Also, because you're changing physics here and not simply displaying a message you need to revert everything if the player restarts the level or when he leaves the level, so you also need to add the following:
Code:function GameConnection::onClientLeaveGame(%this)
{
revertphysics();
if (isObject(%this.camera))
%this.camera.delete();
if (isObject(%this.player))
%this.player.delete();
}
function State::ready()
{
revertphysics();
serverPlay2d(ReadyVoiceSfx);
PlayGui.setMessage(ready);
$Game::StateSchedule = schedule( 1500, 0, setGameState, set);
}
To avoid bugs if you are using checkpoints, make sure the player can't go OOB while in the trigger.
Gl and inform me if you get issues