Timeline for Collisions being detected before objects are intersecting
Current License: CC BY-SA 3.0
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 16, 2020 at 10:15 | history | edited | CommunityBot | Commonmark migration | |
| Mar 22, 2016 at 21:09 | answer | added | Khlorghaal | timeline score: 1 | |
| Mar 22, 2016 at 21:01 | comment | added | Khlorghaal | By deleting from a list while iterating it you'll get undefined behavior. Use a copyOnWrite container, or cache your delete indices and apply them after. Edit: oh by setting the pointer to null and doing a check thats fine | |
| Mar 17, 2016 at 4:16 | comment | added | loremIpsum1771 | @HidekiAI The origin is in the center of the screen | |
| Mar 17, 2016 at 2:00 | comment | added | HidekiAI | Just so that we are clear, is your origin (your screen coordinates) at bottom left to be (0, 0)? I'm assuming bottom of the screen is Y=0, because your calculation shows bulletBottom = BulletCenter.Y - h/2 and bulletTop = center.Y + h/2 (so Y-up), but your X for the enemy is negative... So now, if I assume origin is dead center of the screen, then the part that would get you is on the negative quadrant, if you're doing 'if (bulletLeft > enemyRight)' it needs to switch to '<'. So, where is the origin (0,0) at? | |
| Mar 17, 2016 at 1:47 | history | edited | loremIpsum1771 | CC BY-SA 3.0 | added 312 characters in body |
| Mar 17, 2016 at 1:45 | comment | added | loremIpsum1771 | @v.oddou I was able to modify the code to make the collisions happen closer to the enemies. I had been scaling the entities by the widths and heights so I decided to reduce the scaling factor. The problem now is that the bullets are taking out two enemies before they are destroyed. I added a link to the full code for reference. | |
| Mar 17, 2016 at 1:19 | history | edited | loremIpsum1771 | CC BY-SA 3.0 | added 140 characters in body |
| Mar 17, 2016 at 1:15 | comment | added | v.oddou | put a breakpoint and inspect the values of the height / width. Use "set next statement" to re-execute the collision check, step in the function, you'll see immediately what is wrong in your condition. At first sight I'd say it looks OK so you have a value problem in your structures. Also the float could play a role. 2d games i've written use integer pixels, float is only used for intermediary calculations. | |
| Mar 16, 2016 at 21:54 | comment | added | loremIpsum1771 | @HamzaHasan I think there is some extra white space but I don't think that it would be enough to make it so that the collisions are detected when the entities are so far apart. I updated the post with an image of when the collision is being detected. | |
| Mar 16, 2016 at 21:52 | history | edited | loremIpsum1771 | CC BY-SA 3.0 | added 206 characters in body |
| Mar 16, 2016 at 19:59 | comment | added | Hamza Hasan | You are checking collision through boundaries, so i think it is not possible to have same value of bullet and enemy at any point. Second is might be possible it is the issue of your image canvas, may be your images have extra white space... | |
| Mar 16, 2016 at 19:10 | history | asked | loremIpsum1771 | CC BY-SA 3.0 |