Copy link to clipboard
Copied
I have a problem :S
I have a gun which shoots a bullet to the mouse.
I have enemies.
The bullet is made with - graphics.lineTo(mouseX, mouseY);
Then is recalculated with - graphics.clear();
graphics.lineTo(enemy.x, enemy.y);
You get the picture...
My problem lies here. The bullet when recalculated draws to the center of the enemy instead of the collision point and Ino why that is happening it because im using enemy.x and enemy.y.
How can I detect the exact collision point of the bullet on the enemy?
because then I can just draw line like this - graphics.lineTo(CollisionPointX, CollisionPointY);
Thanks
Copy link to clipboard
Copied
What are you describing as "the collision point of the bullet"? What determines where that is?
Copy link to clipboard
Copied
Im not sure, I need to find the exact point where the bullet collides with the enemy so then I can draw a line to that exaxt point
Copy link to clipboard
Copied
Either the exact point where the bullet collides or some kind of formulea to keep the inline with the mouse
Copy link to clipboard
Copied
If you make the bullet so that its registration point is at the exact point where contact is made then you can use the x/y properties of the bullet. If you cannot do this for some reason, you should still be able to determine where that leading edge/point of the bullet is relative to its registration mark.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now