Jump to content

Changing physics on an entity without doing a physics update can cause issues (like revive sliding)


hoxi
  • Pending

A good example of this is, as mentioned in the title, is how reviving a ghost player and then pushing them, results in them sliding away with any velocity they gained, until they exit the state (they still collide and can get caught on things). Like any applied velocity doesn't deaccelerate to stop on its own, only if colliding with something else, as if the physics component is partially asleep or something.

-- line 396 in player_common_extensions.lua
MakeCharacterPhysics(inst, 75, .5)

Doing even a Physics:Stop() call after this prevents it from happening, setting motor velocity also works.

 

Any case of physics being changed needs to be sanitized to do some sort of physics call afterwards, or this will happen.

 

Also, something that could maybe be looked into as well, somewhat related to this?

function MakeCharacterPhysics(inst, mass, rad)
    local phys = inst.entity:AddPhysics()
    phys:SetMass(mass)
    phys:SetFriction(0)
    phys:SetDamping(5)
    phys:SetCollisionGroup(COLLISION.CHARACTERS)
	phys:SetCollisionMask(
		COLLISION.WORLD,
		COLLISION.OBSTACLES,
		COLLISION.SMALLOBSTACLES,
		COLLISION.CHARACTERS,
		COLLISION.GIANTS
	)
    phys:SetCapsule(rad, 1)
    return phys
end

All of the Make[something]Physics functions will create a new physics engine component for an entities that already have one, rather than modifying things. I think it does get cleaned up, but I'm not sure.. but regardless it's still kinda not the most ideal..?

I know for a fact it does get replaced because I tried storing the one that gets replaced, and then comparing it with the new one, and they're indeed different.

Maybe a new function for the physics component could be made to reset the component back to a clean state as if it was a new one, instead of doing this? Or maybe a lua function, not necessarily on the engine.


Steps to Reproduce
  • Revive a player who's currently a ghost, with a Telltale Heart or so.
  • Walk into them.
  • Notice how they'll be pushed but then slide continuously until they exit that state.
  • Like 2
  • Shopcat 1
  • Big Ups 1



User Feedback


personally I always wished we had a physicstweener because the current methods to change physics size on-the-run really suck since the target gets teleported to 0,0,0 each call

Edited by Well-met
  • Like 1

Share this comment


Link to comment
Share on other sites

6 hours ago, Well-met said:

personally I always wished we had a physicstweener because the current methods to change physics size on-the-run really suck since the target gets teleported to 0,0,0 each call

That.. probably has to do with the second thing I mentioned, where another physics component is created and the old one is replaced, instead of modifying the existing one. I guess it could make some sense, it's making a new one, therefore it's initializing which by default could mean 0, 0, 0 for the physics component specifically, if it doesn't check for Transform coordinates and grab those on the engine.

It's not always done like this though, some functions use the ChangeTo[something]Physics functions rather than the Make[something]Physics. If the need is to get a clean physics component state, there should be something that does so properly, rather than replacing and garbage collecting the old one.

I thought I did make sure to check, but to be extra sure, I'll double check if doing things this way is what causes the weird sliding behavior mentioned in the report, and make another comment here.

 

That said, having more tools like a physicstweener as you said, would be nice.

Edited by hoxi
  • Like 2

Share this comment


Link to comment
Share on other sites

On 2/28/2026 at 12:09 AM, hoxi said:

I thought I did make sure to check, but to be extra sure, I'll double check if doing things this way is what causes the weird sliding behavior mentioned in the report, and make another comment here.

Even if not making a new physics component and garbage collecting the old one, the issue I reported here (like pushing a player in the process of reviving causing them to slide), still happens. So regardless it seems like, some sort of physics update is needed.

 

There's even cases like this where it's kinda acknowledged:

inst.Physics:SetMass(1)
inst.Physics:SetDamping(0) --might have been changed by quaker
inst.Physics:SetCollisionGroup(COLLISION.ITEMS)
inst.Physics:Teleport(inst.Transform:GetWorldPosition()) --force physics to wakeup

Or silently acknowledged, like in the same file that does the MakeCharacterPhysics call for the player being revived, but in this case for when turning into a ghost:

MakeGhostPhysics(inst, 1, .5)
inst.Physics:Teleport(x, y, z)

 

So ideally, the revive slide issue should be addressed, given that the transition into a ghost does it fine, and the other stuff should probably be addressed too.

I do feel like a function like Physics:ClearParameters() or Physics:Reset() or so could be useful, but regardless, there shouldn't be cases of making a new engine component and throwing out the old one, that feels like asking for trouble.

And I guess there needs to be notes for exceptions like the revive state and turning into ghost states having to force wake up physics because those states otherwise don't do anything related to physics until they're exited.

Edited by hoxi
  • Like 1

Share this comment


Link to comment
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...