Is it posible to make a floor that breaks when u step on it?

Post topics regarding Level Building/Design and Entity Usage with Reality Factory
Post Reply
Wolf Lord
Posts: 11
Joined: Mon Sep 21, 2009 7:47 am

Is it posible to make a floor that breaks when u step on it?

Post by Wolf Lord » 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.

Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Re: Is it posible to make a floor that breaks when u step on it?

Post by Jay » Tue Oct 06, 2009 10:45 am

You have three alternatives:

1. Making several world models (in the editor) that show a crumbling floor, then them as a Door or using MovingPlatform entities. You must link them together with the NextToTrigger field.

2. Making an actor (in your modelling program) that has a 'break' animation, then add it as a Pawn entity with a script so that when something touches it / is over it, so that it breaks, then the collision is turned off.

3. The third alternative would be to use a mixture of both, i think that would be harder than both of them.


No. 2 would be the easiest, i think.
The base script for the Pawn could look like this:

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
  } ]
}
Everyone can see the difficult, but only the wise can see the simple.
-----

Wolf Lord
Posts: 11
Joined: Mon Sep 21, 2009 7:47 am

Re: Is it posible to make a floor that breaks when u step on it?

Post by Wolf Lord » Tue Oct 06, 2009 11:53 am

Thanks, I'll try it out this afternoon.

Post Reply