Allowing player to draw circle around enemies. Best method?

Hi all,

I hope I’m posting this in the right forum, feel free to move it if I haven’t.

I’m currently trying to design a mechanic where the player can run around an enemy. As the player runs around, their positions are saved. Should the game detect that the player has ran an enclosed shape (say, a rough circle), any enemy inside that area will be destroyed.

For an example of what I want to do, this video here shows an old game which does a similar thing:

I’ve been trying to figure out the best way to do this. People have suggested creating a mesh, but I think that may be too complex for this, especially since I won’t know what the shape will be.

Does anyone have suggestions on how to pull this off?

Make note of points as the player moves, create line segments between them. If a new segment intersects an existing one, you have formed a closed shape. Intersection point is a new point needed to create shape. Then find if other points are inside it. Remove oldest segments once you reach a certain number.
There are algos for all this easily searchable with google (line intersection, point within polygon)

You can use PolyContainsPoint for detecting what’s inside the closed shape, once you have that (just loop through the positions of any existing enemies), and Vectrosity for the line drawing.

–Eric

Thanks for the suggestions, I’ll look into them.

What of actually creating the shape, though? Is creating a mesh from the points the best way to go about it? I’m worried it may be a bit too complex considering I won’t know what the shape will be.

That’s what Vectrosity does.

–Eric

Sorry to reply to such an old reply but I’m trying to do a similar thing to what the OP was doing and I am very new to coding and scripting could you explain a little more as to what the script would look like if you did exactly what the gif is doing? or send me to a link where i could find such explanations. thank you!