Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script for proper physic enabling[MAP START]
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#10
RE: Script for proper physic enabling[MAP START]

Make sure all your dynamic entities are not colliding with the object they are standing on. I always use a small spacing on the grid and have most of my dynamic entities start slightly off the ground, which avoids the problem for me by having all the objects collide at slightly different times at the start. If your entities are placed correctly (I.e no collisions using create on surface or fine-grid placement), and you do not have an obscene amount of them, you should not be having to find a scripted solution to this problem.

However, if you really want a scripted solution, one idea is to use prefixing, and something along the following lines:
Entity naming conventions:

Stage 0 entities: s0_<NameHere>
Stage 1 entities: s1_<NameHere>
...
Stage n-1 entities: s<n-1>_<NameHere>

Eg: s0_book0, s1_book1, s1_book2 etc
Specify n in the code, along with the time between activations.
Entites which do not follow this naming convention will obviously not be effected. Entities which do follow this convention will only be effected if they are set to deactivated inside the editor.

Again. This is very hackish. You shouldn't be having this problem.
//Sample code (Completely untested!)
void OnStart()
{
cbTmrActivate("Blah");
}


const float _activateTimeStep = 0.05f; //Time between activations
const int _activateStages = 4; //Number of stages to activate.
void tmrActivate(string &in asTimer)
{
//Read in the stage of the timer
int stage = GetLocalVarInt("tmrStage");

//Activate this stage of dyn-props
SetEntityActive("s"+stage+"_*",true);

//Next Stage
stage++;
if(stage == _activateStages) return;

//Writeback the var, loop the function.
SetLocalVarInt("tmrStage",stage);
AddTimer(asTimer,_activateTimeStep,"tmrActivate");
}

Of course, setting up the naming conventions, and de-activating all the props that are to be re-activated in stages is really much more time-consuming and difficult than just moving the entities so that they are not longer colliding at that start of the map.

If you do have a lot of entities over a huge area, this can be used with script-areas and some parsing to extract numbers from the collided script-entity and activated the appropriate section of objects as a form of physics de/re-activation, but i highly doubt you have a map big enough for this problem to occur, and it may be prone some some quirky behaviour if not set up correctly.
(This post was last modified: 07-23-2011, 03:12 AM by Apjjm.)
07-23-2011, 03:09 AM
Find


Messages In This Thread
RE: Script for proper physic enabling[MAP START] - by Apjjm - 07-23-2011, 03:09 AM



Users browsing this thread: 1 Guest(s)