Back to NxLabs

NxLabs / Vintage Story

PhysicsLib - Solid boats and entities

DBy Davis99

This mod implements a long awaited feature - solid entities!

PhysicsLib - Solid boats and entities

Description

After many moons of coding to determine how on earth player motion is controlled by vintage story, i present to you PhysicsLib - Solid Entities.

 

On its own, solid entities only makes the vanilla sailboat walkable, but it opens the door for any modder to patch existing entities or implement their own with solid collisions!

 

Mods Currently leveraging PhysicsLib:

 

Spoiler!

VS Airships

Shipwrights

 

 

How does it work?

 

Physics lib is simple, it implements 1 entity behaviour which can be patched onto existing entities, or leveraged directly within mods - behaviour code: "dynamic-physics".

With this one entity behaviour attached, every cube in the shape file of the model will be used to build up a dynamic collision box for the shape of the entity, and then caches it to be reused for every instance of that model.

 

In order to prevent EVERY cube being used, wildcard selection can be used against the cubes of the model.


(For Modders/Asset creators) How to set it up for your own entities, or patch existing ones:

 

  1. Remove the ellipsoidalrepulseagents from the entity(if present, otherwise your fancy new solid entities will be pushed away from your own hitbox)
  2. Add the physicslib behaviour with code "dynamic-physics" to both the client and server behaviours of the entity.
  3. Optionally, supply a "selectors": [] object with a list of selectors for the list of cubes in the model youd like included in collision.

 

Example Patch for the vanilla sailboat, the first 2 sections remove ellipsoidrepulseagents behaviour, the next 2 add the behaviour to client and server:

<pre>&nbsp;</pre>
Spoiler!
<pre>[ { "file": "game:entities/nonliving/boat-sailed", "op": "remove", "path": "/server/behaviors/0" }, { "file": "game:entities/nonliving/boat-sailed", "op": "remove", "path": "/client/behaviors/0" }, { "file": "game:entities/nonliving/boat-sailed", "op": "addmerge", "path": "/server/behaviors", "value": [ { "code": "dynamic-physics", "selectors": [ "ORIGIN/ORIGIN-Section1/", "ORIGIN/ORIGIN-Section2/", "ORIGIN/ORIGIN-Prow/", "ORIGIN/ORIGIN-Prow2/GunwhaleS4/", "ORIGIN/ORIGIN-Prow2/GunwhaleN4/", "ORIGIN/ORIGIN-Prow2/ProwFloorS6/", "ORIGIN/ORIGIN-Prow2/ProwFloorN5/" ] } ] }, { "file": "game:entities/nonliving/boat-sailed", "op": "addmerge", "path": "/client/behaviors", "value": [ { "code": "dynamic-physics", "selectors": [ "ORIGIN/ORIGIN-Section1/", "ORIGIN/ORIGIN-Section2/", "ORIGIN/ORIGIN-Prow/", "ORIGIN/ORIGIN-Prow2/GunwhaleS4/", "ORIGIN/ORIGIN-Prow2/GunwhaleN4/", "ORIGIN/ORIGIN-Prow2/ProwFloorS6/", "ORIGIN/ORIGIN-Prow2/ProwFloorN5/" ] } ] } ]</pre>

Download

No download link is available for this entry right now.

Ratings & reviews

No ratings yet

Sign in to leave a rating or comment.