New answers tagged

3

After getting help from @DMGregory I was able to solve this by : Getting the center of the toppingsA and toppingsB Finding 6 most far toppings from the centers generate 2 polygons based on these 6 vertices for each topping check if polygons have the minumum area needed to cover most of the half and that they don't collide This gives accurate half-half ...


1

This is probably not the best solution in terms of performance but the easiest thing you could do (and this may be okay if you limit the number of toppings) would be to iterate though all topping positions and check the angles between them (you can find someone looking for a similar solution here) This would require iteration through an array while in array ...


-1

One simple but likely good enough solution would be to brute-force it. Try many different possible pizza layouts and rate the player based on the one which is most favorable to them. For the half-and-half layout, you could calculate the layouts with lines of separation in increments of 10° to get 18 different ratings (the other 180° would be redundant as ...


1

You can configure the layer collision matrix in the Physics settings of your project so your gameobject in a particular layer interacts or not with other layers You can find it in Edit > Project Settings > Physics


0

struct Rectangle { //top left corner float ax; float ay; //bottom right corner float bx; float by; }; bool collision(Rectangle A, Rectangle B) { if(A.bx >= B.ax && A.ax <= B.bx && A.ay >= B.by && A.by <= B.ay) { return true; } else { return false } } I'm pretty sure this is the ...


0

Well If you're asking about purely preventing an invevitable movement, then simply checking the position of your proposed movement against the collision bounds of your player and the wall And adjusting the player's position back out of the wall will do just fine. However, if you want to prevent the initial movement altogether, then you need to look at ...


1

This is an interesting question. It's possible to do this with a huge sprite representing the maze, using a sprite mask to ensure only the walls are part of collision. I'm not sure that's a good way to go, but it is relatively simple. When the sprite is created, you must be sure to create the mask: self.image = pygame.image.load( maze_image ).convert_alpha(...


0

So is the problem that when the player is moving in both directions at the same time a collision is detected and the player stops moving? You can either redo the whole collision detection function which probably isn't a bad idea or simply try moving in each direction separately and see if that works.


0

Your method signature must match the one given in the documentation. OnCollisionEnter2D takes a Collision2D argument, not a Collider2D argument as you've used here. Because your signature doesn't match, Unity finds no matching OnCollisionEnter2D(Collision2D collision) function to call, so it doesn't call it.


Top 50 recent answers are included