Why Does Sonic Never Collide?

Hello boys, girls and David Baszucki himself. So, I’m making a classic Sonic game and Sonic never collides with a part. I have a part called “BottomHitbox” which I’m using to detect collisions at his feet. If I shouldn’t do this, how do I check if a part was touched on a certain face?
Here is the main script for Sonic:

local speedX = script.Parent.Variables.speedX.Value
local speedY = script.Parent.Variables.speedY.Value
local falling = script.Parent.Variables.falling.Value
local bottomCollisions = script.Parent.Variables.bottomCollisions.Value

wait(10)

--GAME LOOP
repeat
	--HANDLING COLLISIONS
	script.Parent.BottomHitbox.Touched:Connect(function(part)
		print(part.Name)
		if part.Name == "Solid" then
			bottomCollisions = true
		end
	end)
	script.Parent.BottomHitbox.TouchEnded:Connect(function()
		bottomCollisions = false
	end)
	
	--GRAVITY
	if bottomCollisions == false then
		falling = 1
	elseif bottomCollisions == true then
		falling = 0
	end
	
	if falling > 0 then
		speedY = speedY - 0.1
	elseif falling < 1 then
		speedY = 0
	end
	
	--MOVING SONIC
	script.Parent.CFrame = script.Parent.CFrame + Vector3.new(0, speedY, 0)
	--script.Parent.BottomHitbox.Position = script.Parent.BottomHitbox.Position + Vector3.new(0, speedY, 0)
	
	wait(0.01)
until false

Here’s the explorer:
Capture

Oh and before I forget, here’s it happening:

Thank you!
-Titanic (6 months ago, now Randomosity)
(also can you tell me why i can not set my display name to titanic thnx)

1 Like

The first thing I would try is to make the bottom collision part thicker to avoid it clipping through the floor. The .Touched events are known to have a slight delay varying at times, making it update to bottomCollisions = true too late.

Either that or you can look into creating a new jump mechanic to move the part’s velocity when pressing spacebar, not having to disable collision at all.

If that does not provide clarity, I suggest you get rid of the command bar and enable the output when you go to ‘View’ at the top of your screen. Then you can show any errors or prints that come through.

1 Like

I’ll try your first suggestion, which might not work because the part to collide with is very tall (since we’re working with the Y axis). But the output window, I already checked in there it’s just not printing anything.

Just tried it and nope, even with the bottom hitbox part scaled upwards more, it still doesn’t detect anything. Next suggestion then.

Also, you have a configuration for variables? That’s the first time I’ve seen that.
Can you share what is in the configuration?

It used to be speedY, falling, bottomCollisions- all the things in the script but now there’s only speedX. Also, I used Scratch too much that I forgot they are called Values instead of Variables. Also also, using the linear velocity:

nevermind the video the file size is too big

Managed to grab a snippet.


Now there’s a new problem: how do I lock the movement on the Z axis for it not to turn and flip and stuff.

1 Like

Actually this way can’t work because Sonic’s hitboxes don’t work like this at ALL, so I have to find it out myself then.


(hope i didnt leak anything confidential) See how those 2 lines are being drawn on either side of Sonic? Using Velocity doesn’t give the same effect, so I need multiple anchor points. Let’s try that.
(If you want to use this lua script to add an overlay to the ROM, you can get it here.)

Why is absolutely no one helping me on this?

Moving via CFrame is probably your issue here.

I changed them from CFrame to Position but Sonic still clips through the floor (did I mention that? he lands but clips a little bit into the floor (most likely because i’m moving Sonic by speedY which keeps getting bigger but I don’t know how to fix that)) and now the camera and side bars don’t follow Sonic.

fixed it… 6 months later. you can learn more here: Sonic 1 Camera not Working