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

Two Objects Following Each Other While Maintaining Minimum Distance

New Here ,
Aug 05, 2013 Aug 05, 2013

Hello,

I'm trying to solve a problem where I have one circle following another ( the first following the mouse ), yet maintain a minimum distance between the two circles.

The code is pretty simple. For the lead circle I'm moving it as follows on the movement of the mouse:

circle.x = event.stageX + 8.000000E-001 * ( circle.x - event.stageX );

circle.y = event.stageY + 8.000000E-001 * ( circle.y - event.stageY );

Then I'm moving the secondary circle as:

circle2.x = circle.x + 8.000000E-001 * ( circle2.x - circle.x );

circle2.y = circle.y + 8.000000E-001 * ( circle2.y - circle.y );

This works remarkably well, however, I want to be able to increase the distance between the two circles and enforce a minimum. If anyone can point me in the right direction I'd appreciate the assistance. Thanks.

TOPICS
ActionScript
545
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
Community Expert ,
Aug 05, 2013 Aug 05, 2013

increase .008 to increase the distance and use if-statements to enforce a minimum.

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
New Here ,
Aug 05, 2013 Aug 05, 2013

Thanks for responding. To what are you referencing that I increase by .008, not following? Thanks.

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
Community Expert ,
Aug 06, 2013 Aug 06, 2013
LATEST

that was supposed to be .8


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