[ALL] Expose VPhysics related functions#1891
Open
ALIEN31ITA wants to merge 2 commits intoValveSoftware:masterfrom
Open
[ALL] Expose VPhysics related functions#1891ALIEN31ITA wants to merge 2 commits intoValveSoftware:masterfrom
ALIEN31ITA wants to merge 2 commits intoValveSoftware:masterfrom
Conversation
This is very usefull, such as FVPHYSICS_PENETRATING, to find out if 2 props are stuck into each other (if not asleep)
Comment on lines
+1512
to
+1521
| void ScriptSetElasticity( float flElasticity ) | ||
| { | ||
| SetElasticity( flElasticity ); | ||
| } | ||
|
|
||
| float ScriptGetElasticity ( void ) const | ||
| { | ||
| return m_flElasticity; | ||
| } | ||
|
|
There was a problem hiding this comment.
Although it is fine but you don't really need to make an wrapper for GetElasticity and SetElasticity since you can just directly define them as VScript functions. Just saying.
practicemedicine
approved these changes
Apr 18, 2026
practicemedicine
left a comment
There was a problem hiding this comment.
I made a little comment around L1512-L1521 regarding how VScript functions are defined, but overall this looks good to me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This Pull Request goal is to make Physics functions exposed to vscript, allowing mappers and scripters to experiment with any entity they wish, by turning them Physical, override their material properties, changing mass, making them float on water and so on.
All the functions should also work on brush entities too! (tested with CreatePhysics, and Setmass for now
API
void CreatePhysics( int nSolidType, int nSolidFlags, bool asleep )void DestroyPhysics()bool HasPhysics()int GetSurfaceProperty()string GetSurfacePropertyName(string name)void SetSurfaceProperty( int surfaceprop )void SetSurfacePropertyByName( string name )void GetMass()float SetMass( float mass )float SetBuoyancy( float buoyancy )void GetElasticity()float SetElasticity( float elasticity )void ToggleCollisionsOn( handle entity, bool Enable )void SetPhysicsFlag( int PhysFlag )bool HasPhysicsFlag()void RemovePhysicsFlag( int PhysFlag )Showcase (of the Most important ones)
sv_turbophysics was turned off for demonstrating this in TF2.
It's kinda hard showcasing demostrating most of them, but i recorded the ones i find to be the most important, and a must have.
MakePhysics(6,0,false)
This is really usefull if you want to convert stuff to have physics, could be an NPC, or specific objects you wish, without requiring you to spawn a prop_physics (or anything physical) and parent it, should work with most entities.
2026-04-17.22-00-15.mp4
GetMass & SetMass
2026-04-17.22-00-25.mp4
ToggleCollisionsOn( used a loop in the example )
The Closest we have is using a logic_collision_pair, or setting the entities collisiongroup to COLLISION_GROUP_BREAKABLE_GLASS, but this gives us filtering, so we decide what to collide with or not (may not work on some entities).
2026-04-17.22-01-10.mp4
GetSurfacePropertyByName & SetSurfacePropertyByName
Let's you override their physical properties without the need of recompiling existing models.
2026-04-17.22-01-33.mp4
I will try Expose more functions, i only found these to be high priority, and easier to make accessible, if anyone has suggestions, or functions that SHOULD be exposed, or want to improve it, let me know.