Ui Bullet Hell / Detecting Touch

Hey there,
I currently am just making a little prototype and have set up a little 2d bullet hell much similar to undertale/deltarune.

However, I have got everything good and ready minus the actual bullets/attacks… I’m not sure how I would go about detecting when they would hit the player or how I would move them.

Would I just do the movement with a Tween and how am I supposed to detect the touching of two uis?

I have used the Ui Collision module (Because it is posted literally everywhere I look) and it is just too much of a mess around to use for myself, although I am not entirely against using it.

I’d appreciate if someone could help me out here.
Cheers.

1 Like

Wrote this on the fly and didn’t have time to test it thoroughly (only did basic testing) so it might not work perfectly. Let me know if there’s any problems.

collision module script

-- AABB collision
return function collision(a: GuiObject, b: GuiObject): boolean
	return
		a.AbsolutePosition.X + a.AbsoluteSize.X > b.AbsolutePosition.X and
		a.AbsolutePosition.X < b.AbsolutePosition.X + b.AbsoluteSize.X and
		a.AbsolutePosition.Y + a.AbsoluteSize.Y > b.AbsolutePosition.Y and
		a.AbsolutePosition.Y < b.AbsolutePosition.Y + b.AbsoluteSize.Y
end

example usage

local collision = require("./collision") -- replace with actual path

-- example usage
game:GetService("RunService").RenderStepped:Connect(function()
	if collision(frameA, frameB) then
		print("Collision detected!")
	end
end)

Note that AABB collision might not be the best solution for a bullet hell, since it only really works for squares. I might be able to make a better one, I don’t know.

if you have fast moving bullets then sometimes hitboxes will pass through players, so you can also make a raycast from the bullet position to its previous position

1 Like

You should probably just look into a 2D collision library like you mentioned, or don’t use Roblox. Roblox isn’t very good for 2D games in my opinion. Deltarune was made in GameMaker, but you could go with Godot, Unity, etc. I wonder if you’ll get your prototype finished before Chapter 5 releases /j

Found this, it might be helpful for you if you choose to stick with Roblox

Thanks but I don’t intend on swapping away from Roblox.
Regardless I have most aspects of the combat system done aside from this.

1 Like

Tried this and it wasn’t very accurate, was firing more than I wanted and when it wasn’t touching the soul/player.

1 Like

Really? That sucks, the topic looked good.

Thinking more about it, I don’t know why I wrote you an AABB collision function. That wouldn’t work well for a bullet hell, since it only works with rectangles. I think circles would probably be better.

Eh its alright I changed this around and got myself a function that basically worked with it.
The bullets I was testing were squares/rectangles so it was fine and I’m not too fussed about the shape of them, just means like a bigger hitbox and if that becomes an issue later then I’ll deal with it then.

Thank you though this did help a lot.

1 Like

If it becomes weird, make hitboxes smaller than the bullets. That might help

That’s quite handy actually good idea, thanks again.

1 Like

I believe Deltarune does the same thing.

The only reason I know is because I absolutely suck and noticed my SOUL moving through bullets during my replay of Spamton NEO the other day.

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