Need help with collision detection heavy mini-game please, is it possible to prevent 'clipping'?

I am trying to build a very physics-centric mini-game with lots of collision detection needed.

I have scripts moving parts around the game which in-turn push other models around the game and this does work 80% of the time. I have ‘tokens’ bouncing around a little arcade machine however some tokens ‘clip’ through the parts instead of being pushed.

Here is a token about to be pushed by a yellow part:
image

But the part ‘clips’ through it instead:
image

I do have about 100 of these tokens in the game and, as I say, it does work most of the time I just wonder if there are some settings to improve the fidelity of the collision detection? or should I have some script to double check any ‘clipping’ and handle that separately?

Is the token a model? Where is it in the game (like in the explorer)

Do you have your part anchord?

1 Like

The token is a model yeah, it’s a added at runtime and it’s stored in replicated storage…

Okay. Select all of the parts in the model and go into the properties tab.

In there, there should be a setting called CollisionMode. Change that to

PreciseDetoxComposition

Or something like that.

Parts are anchored yes…

Thanks :slight_smile: I just changed the CollisionFidelity to that on the main part of the model… seems better, but it is still happening…

Try changing the CollisionFidelity for all the parts.

1 Like

I’m sure I’m being an idiot I can’t find it on the other parts :frowning: will Google that! thanks for your help! image

1 Like

So I understand now that because the other game parts are just basic geometry they have no CollisionFidelity property so that makes sense.

Looks like my problem remains… I’m going to start looking at rolling my own scripts to determine when tokens are inside other parts. In your experience should the Roblox physics engine be good enough to handle these collisions without having to write custom lua to help? (I’m very new to Roblox dev)

I’m pretty sure the current physics should be fine. The tokens may be clipping because the are too small. Maybe try making them a bit larger?

1 Like

If you replace the coins with different types of meshes do you get different effects? like surely a cube mesh with a decal on (so it looks like a round coin) would be the most efficient, i’d expect cylinders to work better than custom meshes, especially if the custom meshes have strange geometry, they probably need to be pretty low poly and based on tri’s rather than quads maybe?
I did some testing, everything works fine for me, i used cylinder meshes for coins, and prismatic constraints to move the pushers. are you using Cframes? that’s almost defiantly the problem

1 Like

Oh wow that looks spot on that test!

So my token model is a cylinder part with decals on it and then another cylinder part which I’ve made a negative union with to make a hole in the middle:
image

Looks like that’s my issue then just my model is too funky! Just stick to a simple cylinder then perhaps.

EDIT: I’m not sure about CFrames? I do use those to rotate the model part to begin with.

(thanks by the way spending so much time on this that demo is awesome!)

yeah make a transparent decal with the cherries on it and it should work hopefully :smiley:

1 Like

So now using just plain cylinders I still get the clipping so now I wonder if it’s how I’m actually moving the pushers! I just have a script setting the pusher’s Position and Velocity. I wonder if using these prismatic constraints is a better way to go?

Could you point me in the direction maybe of a good tutorial for doing what you did in that video please, moving the pushers via lua using prismatic constraints?

This looks like it covers all the stuff you’ll need to know https://www.youtube.com/watch?v=c_LUsy4_91o

1 Like

I’m still really struggling with this :frowning:

I’ve created a brand new workspace with just a handful of parts and the sliders now move using very simple Prismatic Constraints.

The counters and now just very simple cylinder parts and nothing is added at run time.

I have just a single script in the the ‘ServerScriptService’:

while true do
	wait(1)
	local pusherPrismaticConstraint
	
	pusherPrismaticConstraint = game.Workspace.Pusher1:FindFirstChild("Pusher1PrismaticConstraint")
	
	if pusherPrismaticConstraint.CurrentPosition >= -2.5 then
		pusherPrismaticConstraint.TargetPosition = -3.2
	elseif pusherPrismaticConstraint.CurrentPosition <= -2.8 then
		pusherPrismaticConstraint.TargetPosition = -2
	end
	
	pusherPrismaticConstraint = game.Workspace.Pusher2:FindFirstChild("Pusher2PrismaticConstraint")
	
	if pusherPrismaticConstraint.CurrentPosition >= -2.5 then
		pusherPrismaticConstraint.TargetPosition = -3.2
	elseif pusherPrismaticConstraint.CurrentPosition <= -2.8 then
		pusherPrismaticConstraint.TargetPosition = -2
	end
end

robloxapp-20200829-1527204.wmv (7.8 MB)

But I still get clipping and really jerky motion. It’s really frustrating I feel like I’m just doing something really fundamentally silly/wrong :frowning:

basically dont use .Position use .Velocity

so do something like

while true do

  • -Go forward
    PrismaticConstrant.Velocity = 10
    wait(5)
  • -Go backward
    PrismaticConstraint.Velocity = -10
    wait(5)
    end

Probably work setting limits too.
it can be done in the studio window
but in code it’d be
prismaticConstraint.LimitsEnabled = true
prismaticConstraint.LowerLimit = 1
prismaticConstraint.UpperLimit = 10