#Help making a cone shape in 2D

1 messages · Page 1 of 1 (latest)

vast tangle
#

I'm trying to make a cone area shape for my 2d game. I kind of want it to be a real cone instead of a triangle, with a curved border.
I was thinking along the lines of, maybe there's like an easy way to mask over a circle shape. So the resulting area is only between two particular degrees. But I haven't found an engine option to implement this.
Otherwise I've been trying out the manual bezier curves but it's a bit messy.

So is there any easy approach I'm missing?

limpid loom
#

you can use Vector2.dot() to check how far off from the direction the other point is. You would pair this with a CircleShape

vast tangle
#

yeah I can see how that would easily handle the collision aspect. But what if I want to display the cone as an area?

#

I already experimented a bit with Polygon2D and an animatedTexture, but making the curves is a problem.

#

oh wait maybe I can use from_angle() to create vectors and find the points I want

#

I'll try that

limpid loom
near fox
#

radially?

vast tangle
#

I'll look into draw_arc, thanks

#

although it only supports a base color?

#

oh nvm "unfilled arc" huh

#

yeah I might need to get into shader territory

near fox
#

bresenhams line algorithm!

vast tangle
#

it seems that's used for straight lines? but my problem are curved ones atm

near fox
#

i actually don't remember how i used to do rendering filling in between the lines haven't done that since 2017 lol

vast tangle
#

another option is giving up for now and use straight lines

#

lol

near fox
#

uh try using curve 2d

#

design the curve you want and then call the tesselate function

#

then use that array as a polygon

#

?

vast tangle
#

that or I could just use cone sprites, since the collision detection is mostly taken care of