Skip to main content
Known Participant
October 16, 2023
Question

line to movieclip collision

  • October 16, 2023
  • 1 reply
  • 2308 views

Dear All Thank you for your time

I have aproblem that cant seem to work out looked on line and read some books but cant find

a solution. I have one movie clip that is tweened on a straight path that is movable with the mouuse

as wel as rotatable with buttons, the imbedde tweened object cabn also be moved with buttons . The collision object is a line that rotates 360deg with a button . That all works, what I cant figure out to do is display the distance to the line as the tweened object approaches the like a countdown to a colision.

added a photo to help explain.

Thank you all

    This topic has been closed for replies.

    1 reply

    kglad
    Community Expert
    Community Expert
    October 16, 2023

    you can get an exact answer for a disc/circle and an approximation for a square using:

     

    first, calculate the line segment's point of collision.

    then, calculate distance between your object's center of that point of collision

     

    if you need a more exact answer, you would need both collision points, the segment and the object.

    Known Participant
    October 17, 2023

    Dear Kglad

    Thank you for your reply

    I am not sure how acomplish to that, as both the object and the ray are on different time lines how and are both capable of moving to diffent places on the screen. I can work it out if static but not each a time a new ray position and a new path is chosen.

    Thank you peter

     

     

    Known Participant
    November 8, 2023

    Dear Kglad

    Thank you for your help

    Yes that is correct also the two drawn lines are not correct as they base there position on the blue and red dots and the refence points of the two lines. Without the dots in the right plus the simulator will not work.

    Is there a way to change the reference of the stage so it aligns with the movi clip position that way the stage acts a local reference not a global one.

    Best Regards

    Peter


    Dear Kglad 

    Thanks for your help

    I have made a simple FLA to aid in trouble shooting the problem, it seems when you pass the cordinates of the scalex and y they do not change the red dots position to global cordinate which is shown as the the same location as the intial position , this is then  passed to the graphic drawn circle. If you use the local to global it uses the location set up for the variable so both dots superimpose on each other.The other weird thing is graphic drawn dot locastion always shows 0,0. When I check "this.greendot.reddot1.localToGlobal(0, 0);" as  formulted by the local to global in the desktop the it shows (261.75,187.3)  wheras the laptop top shows  (654.375,468.25) yet the initial positions of the console log for both red and green dots are the  same on both computers.

    Best Regards Peter