dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: collision detection with mouse dragging problem

Hybrid View

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    211

    collision detection with mouse dragging problem

    I am making a maze game. At first I was just using keyboard controls to move the character through a maze. This is fairly siomple to do because flash has more time to calculate a collision and prevent the character from moving through the wall. But I want to be able to drag the character through the maze with the mouse. This works ok when the dragging is slow. But once you move the mouse really fast, the character goes right through all the walls.

    Does anyone have a good way to fix this?

    I am using pixel perfect collision detection if that helps.
    -FRIG-5
    Das Konzept Design
    www.daskonzept.com

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You will need to test whether the line between the character's last position and current position intersects with the maze. If the maze is static, this isn't too difficult. If it's moving, then it gets tougher.

  3. #3
    Senior Member
    Join Date
    Apr 2001
    Posts
    211
    ahhh... hadn't thought about that. Thank you.
    -FRIG-5
    Das Konzept Design
    www.daskonzept.com

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Consider giving your character a direction instead of 'moving' him, so your mouse gives him velocity toward the cursor but doesnt just teleport him to it's location.

  5. #5
    Senior Member
    Join Date
    Apr 2001
    Posts
    211
    Yeah, I tweened him to the mouse position with an ease and a time of .5. Then drew a line between him and the mouse and if anything is inbetween then he stops. Works great. Thanks for your help.
    -FRIG-5
    Das Konzept Design
    www.daskonzept.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center