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]
Rel Offline
Junior Member

Posts: 21
Threads: 5
Joined: Jul 2011
Reputation: 0
#1
Exclamation  Script for proper physic enabling[MAP START]

So i was thinking.

With the amount of objects with physics, is there a script to make sure all the physical props dont just all act physical on a maps start

By that i mean, usually you wont get every prop to be touching a surface perfectly so there wouldnt be any interaction on a maps load, and having every prop use physics at once could cause some annoying stutterting/freezing/ and possibly crashing on lower end machines.

Is there a script or a good way to have it so you can trigger when you want physics to load for props so they dont just all go at once?
07-22-2011, 06:03 PM
Find
MrCookieh Offline
Member

Posts: 157
Threads: 8
Joined: Jul 2011
Reputation: 0
#2
RE: Script for proper physic enabling[MAP START]

One possible way would be to fade out the screen OnStart instantly, so you won't notice it.
Don't know if there's such a function

The Well: Descent - Take a look at it!
07-22-2011, 06:04 PM
Find
Rel Offline
Junior Member

Posts: 21
Threads: 5
Joined: Jul 2011
Reputation: 0
#3
RE: Script for proper physic enabling[MAP START]

(07-22-2011, 06:04 PM)MrCookieh Wrote: One possible way would be to fade out the screen OnStart instantly, so you won't notice it.
Don't know if there's such a function

Its not as much as seeing it happen, but more for optimizing, having so many things interact and use physics all at once cant be good.
07-22-2011, 06:10 PM
Find
MrCookieh Offline
Member

Posts: 157
Threads: 8
Joined: Jul 2011
Reputation: 0
#4
RE: Script for proper physic enabling[MAP START]

well, you can't see the lags too, and I don't think too many things using physics in the beginning, won't break the following game

The Well: Descent - Take a look at it!
07-22-2011, 06:24 PM
Find
Rel Offline
Junior Member

Posts: 21
Threads: 5
Joined: Jul 2011
Reputation: 0
#5
RE: Script for proper physic enabling[MAP START]

(07-22-2011, 06:24 PM)MrCookieh Wrote: well, you can't see the lags too, and I don't think too many things using physics in the beginning, won't break the following game

aight thats good to know, because i know some game engines do, like when some random person makes a map but all the physical props drop or move at the start causes crazy lag and stuttering

Perfect example is TTT in gmod, at the round start it spawns a ton of weapons randomly around the map and causes bad stuttering for a few seconds.

good to know this wont.
07-22-2011, 06:38 PM
Find
GraphicsKid Offline
Senior Member

Posts: 258
Threads: 34
Joined: Dec 2010
Reputation: 3
#6
RE: Script for proper physic enabling[MAP START]

It does that on a few of my maps in Amnesia. Dodgy
07-22-2011, 06:56 PM
Find
MrCookieh Offline
Member

Posts: 157
Threads: 8
Joined: Jul 2011
Reputation: 0
#7
RE: Script for proper physic enabling[MAP START]

Rel Wrote:aight thats good to know, because i know some game engines do, like when some random person makes a map but all the physical props drop or move at the start causes crazy lag and stuttering

Perfect example is TTT in gmod, at the round start it spawns a ton of weapons randomly around the map and causes bad stuttering for a few seconds.

good to know this wont.

Well, I said I don't think so, not sure if it really does. But I've never encountered heavy lags in my own map.

The Well: Descent - Take a look at it!
07-22-2011, 07:02 PM
Find
Rel Offline
Junior Member

Posts: 21
Threads: 5
Joined: Jul 2011
Reputation: 0
#8
RE: Script for proper physic enabling[MAP START]

(07-22-2011, 07:02 PM)MrCookieh Wrote: Well, I said I don't think so, not sure if it really does. But I've never encountered heavy lags in my own map.


It would only be for a few seconds at map start anyways.
07-22-2011, 07:10 PM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#9
RE: Script for proper physic enabling[MAP START]

When placing entities, use the create on surface option as often as you can. This way you can avoid the physics lag at the beginning. Also, the fade-in option is always a good choice.

07-23-2011, 02:05 AM
Find
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




Users browsing this thread: 1 Guest(s)