Extreme Lag Caused By newStepContacts?

My game becomes extremely laggy when players are within the vicinity of two or more spike traps. I’ve narrowed it down to the spike trap’s touch function. However, even when the content of the touch function is empty, it still lags like crazy. Does anyone know what the microprofiler is referring to?

1 Like

Does this still happen when you comment out the touched function altogether rather than just its contents?

Objects with touched events bound tend to act a bit differently physics wise, plus the connection being triggered in the first place rather than what it’s doing is likely the greater cause.

The only time I’ve ever had a touch function lag is when I forget to put in a debounce. But assuming you haven’t done that, this is very strange. Could you possibly post the code you’re using?

It doesn’t lag when there is no touched event, but it does lag when only the contents is commented out.

I take it the spikes are unions or meshparts, does setting the collision fidelity to box help?
(Some people have contact points as invisible bricks)

Should make solving “is this in contact with another nearby part or not” easier, but I don’t know to what degree, as it’s heavily dependent on geometry.

If the spike traps are all one union this likely won’t work since you’d be unable to go into the trap.
You may need to separate the spikes (maybe into 1 union per wall) first if this is the case.

All the unions are box collisions already.

Can you set up a collision group for the spike trap to ignore itself?
Or only listen for player characters?

I guess but the only thing it’s touching are player characters…

See if the player characters’ collision fidelity is set to box if they’re R15.

I don’t think so but would it really cause lag this extreme?

Yeah.

If something’s not set to box, the touch function goes insane for some reason.

1 Like

How do you even set the collision fidelity of character parts?

Wait I just checked. All my character parts are box collision already.

Well if it only lags when a character touched it you’ve found out or significantly narrowed the possible causes.

Yeah I am so lost. :sad:
Maybe I’ll try replicating it on an empty baseplate.

Sorry for lack of response after my original post. I have been unable to replicate this issue. Sorry!