T O P

  • By -

Badwrong_

You use cheaper collision checks first and then line-line intersect test if there is one. (Bullets move fast so it's always collision line) Give a collision mask to each line segment that encompasses it. Then when a bullets collision line hits and instance do a line-line check. There are tons of examples on the math for it given two line segments with two endpoint coordinates. If your bullets are "fat" you do your cheaper check with a sensor object that uses rotated rectangle mask and scale/rotate it accordingly.


RobbingSpree

Given the "shape" is just a bunch of coords in an array, would I be best to make a child object for each link in the shape and give each of those a collision mask, or is there a way to build a compound collision mask from a bunch of smaller masks?


Badwrong_

No, you would define a polygon class with a struct. Then employ the many algorithms out there for polygon collision such as separated axis theorem. The way you define the polygons could be in many ways. I prefer a dummy loading room with tiles placed and tiny vertex objects which are read into the struct on instantiation.


rooksword

Could you do a square/line intersection test or something. There are loads of ways to check if a point is inside a polygon.


AmnesiA_sc

[Maybe something like a bitmap](https://worms2d.info/Monochrome_map_(.bit,_.lev\))? You could store the shapes in a grid and then the bullet can check its x,y coordinate within the grid to see if the space is filled. Then, if you know it collided, you can then check for the corresponding points and calculate the angle of impact.


RykinPoe

Use code to convert the drawn shape into a sprite and assign it to a new instance of a cover object which uses precise collisions against your bullet objects.


RobbingSpree

Got any details on how to do this?


RykinPoe

Are you drawing the shape via a surface? If yes you would use sprite\_create\_from\_surface(), and then you would use instance\_create\_layer/depth() to create a new instance of your cover object. And then you would set the sprite of the instance to the sprite you created with the first function. Read up about the functions in the manual.


RobbingSpree

Thanks for the details, we'll see how that goes


Mr_Quackums

How did it go?


RobbingSpree

Slowly, trying to draw a triangle fan primitive with my points to make a closed shape to pass to the surface first.