Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Collision?

Participant ,
May 31, 2013 May 31, 2013

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

TOPICS
ActionScript
563
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 31, 2013 May 31, 2013

What are you describing as "the collision point of the bullet"?  What determines where that is?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 01, 2013 Jun 01, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 02, 2013 Jun 02, 2013

Either the exact point where the bullet collides or some kind of formulea to keep the inline with the mouse

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 02, 2013 Jun 02, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines