Archived [Pseudocode]PhysicsBlockHardeningSystem

Kazimir3701

New Member
Contributor
Warning: I'm still trying to get my bearings in the engine, and I'm a code novice in general. Most of this stuff will be horrifically inefficient.

Simple system for replacing physics entities that have stopped moving.

Code:
PhysicsBlockHardeningSystem

/*Add to physics entities that are supposed to settle*/
/*Unknown Variable Type*/ previousBlockLocation;
int hardenTimeout;
int hardenTimeoutCap; //For configuring how quickly blocks harden


/*loop this every X seconds*/
for (physics block : active physics blocks){
    if (CurrentLocation != previousBlockLocation)
        previousBlockLocation = CurrentLocation
    else
        hardenTimeout ++;
        if (hardenTimeout >= hardenTimeoutCap)
            /*spawn a matching non-physics block*/
            /*delete this entity*/
 
Last edited:

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
I figure this would probably become an UpdateSubscriberSystem that would fetch entities involved with physics blocks. I wonder if there is enough information involved there already to make a determination if a block has "settled" or when the last movement was. Then you could just loop through the blocks and see if enough time has passed and if so pop in a regular block :)

Just need to find the associated bits of code. It can be tricky to get started, and physics isn't the easiest stuff, but hang in there!
 

Michael

Moderator
Contributor
Architecture
I'm pretty sure that bullet has a rest state for physics objects. I'm not sure how this would optimize game objects unless I'm missing something.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
The good news is that this coincidentally did get some effort not too long ago! @Josharias optimized the railgun and related physics, including tweaks like this. Can probably consider this complete actually :)
 
Top