Odd collision anomaly when CFraming part

So I have these spinning doors which rotate to open and close pathways. One door rotates at a 180 degree offset to the other. However, I’ve found that I can phase through the door with the offset. Collisions completely break with it despite CanCollide being set to true; touch events don’t even work. The collisions only seem to break with the offset applied. The bug/anomaly only occurs in the studio client, I’ve discovered; it seems to work fine in the player client.

I’ve set up a test place so you can try for yourself: test.rbxl (70.5 KB)

On the left, the doors rotate the same as each other, and the collisions on both doors work fine. On the right, the offset is applied to the red door. And the collisions break.

Both collisions working as normal on the left doors:
demo1

Collisions on red door not working on the right doors:
demo2

Both rigs are exactly the same, the only difference is the 180 degree offset in the script:

Hope someone can find out what’s going on here! Thanks in advance.

2 Likes

I don’t know exactly what’s going on here, but my guess would be that it has to do with CFraming the part completely to the opposite side of the axle out of sync with the physics engine step. In general, setting CFrame of a part from a server script does not respect collisions.

The safe way is to use the Motor6D’s you’ve already made as they were intended. For example, try replacing your Script with this:

    sp1=script.Parent.Spinner1.HalfCirc.Hinge
    sp2=script.Parent.Spinner2.HalfCirc.Hinge
    sp1.C1 = sp1.C1 * CFrame.fromOrientation(0.5*math.pi,0,0)
    sp2.C1 = sp2.C1 * CFrame.fromOrientation(0.5*math.pi,0,0)
    sp1.C0 = sp1.C0 * CFrame.fromOrientation(-0.5*math.pi,0,0)
    sp2.C0 = sp2.C0 * CFrame.fromOrientation(-0.5*math.pi,0,math.pi)
    sp1.DesiredAngle = 1e9
    sp2.DesiredAngle = 1e9
    sp1.MaxVelocity = 0.01 * math.pi
    sp2.MaxVelocity = 0.01 * math.pi

The 4 fromOrientation lines are just to fix the orientation of the Motor6D axes relative to the parts. The motors are not aligned for the direction you want the doors to rotate. You can fix this once from the command line and then not actually need it in the runtime script. In fact, if the doors always spin, and at the same speed, no script is even needed. The motors will spin for the life of the server because of the arbitrarily large Desired Angle and slow rotation rate (unless your server stays up > 2.5 years :grin:)

2 Likes

Thanks, this fixed the collisions and the animation is much smoother now too. :smiley:

When you let the Motor6Ds turn things, you get the benefit of client-side interpolation smoothing out the movement. When you set CFrames manually from server scripts, clients see positions update only as the property changes actual replicate, which is much less frequent and can be irregular. Note also that the stuttering of server-side CFraming is not visible even in Accurate Play Solo, since it is a consequence of real internet latency.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.