Is it posible to make a floor that breaks when u step on it?
Posted: Thu Oct 01, 2009 1:12 am
Is it possible to make a floor that breaks when you walk over it? If it is, can someone please tell me how to do it? Thanks in advance.
Let your game become a reality!
http://forum.realityfactory.info/
Code: Select all
{
Spawn[ ()
{
SetGroup("Static"); //So that enemies won't attack it
Console(true); //let's look if this script works
Gravity(false); //Gravity is off or it would fall down
LowLevel("LookIfSomebodyComes");
} ]
//A variable in which we store the thing that we detected
TRACERESULT [FALSE]
LookIfSomebodyComes[ ()
{
//this is executed every frame
//Use TraceToActor which looks if anything is in the way of it's "beam"
TRACERESULT=TraceToActor("",0,50,0); //I used an "upward beam" length 50, you should play around with it
if(TRACERESULT="Player") //we hit the Player, if you are using a ScriptedPlayer you must
{ //change "Player" to the entityname of the ScriptedPlayer
HighLevel("Break");
return;
}
} ]
Break[ ()
{
//play "break" animation for it's full length
PlayAnimation("break", true, ""); //the last parameter can be changed into a "break-sound" e.g. "break.wav"
SetNoCollision(); //fall trough now
Gravity(true); //it falls down to until it meets the floor
FadeOut(10,0); //slowly fade out (10 seconds)
Remove(true); //end script
} ]
}