Character movement if collision logic

This is a discussion on Character movement if collision logic within the Game Programming forums, part of the General Programming Boards category; In case character collides with a stationary object, do... Apparently setting character x or y velocity to 0 doesn't work ...

  1. #1
    Novice programmer newn's Avatar
    Join Date
    Aug 2010
    Posts
    59

    Character movement if collision logic

    In case character collides with a stationary object, do...
    Apparently setting character x or y velocity to 0 doesn't work well, as he can't move to the other side then. Teleporting character -+1px doesn't work either, because it looks horrible. So what logic can I use then? I couldn't think of anything else...

    If you didn't get the question, ask about it and I will explain.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,668
    Draw it out on graph paper and work out the maths.

    Randomly hacking lines of code won't get you there, although you might eventually stumble upon something close enough.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Novice programmer newn's Avatar
    Join Date
    Aug 2010
    Posts
    59
    Thank you, that really helped! Solved this problem very easily, seems like one fact in my imagination was masking another one.

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    So how did you solve it and what did you do? There will be other people reading this thread later on and it would be nice if you shared your approach with the community.

  5. #5
    Registered User
    Join Date
    Nov 2010
    Posts
    16
    It might help you: I've had a similar issue and I ended up calculating the character path before allowing it to move (upon clicking to desired location) to calculate the object moving route in a manner it'd walk around objects it cannot pass thru, taking it to his final location

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Hennet View Post
    It might help you: I've had a similar issue and I ended up calculating the character path before allowing it to move (upon clicking to desired location) to calculate the object moving route in a manner it'd walk around objects it cannot pass thru, taking it to his final location
    If I were grading this, I might give you A Star!


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 07-05-2011, 08:21 PM
  2. Character Movement
    By binks in forum C Programming
    Replies: 44
    Last Post: 04-27-2011, 11:45 AM
  3. Replies: 14
    Last Post: 08-24-2010, 04:13 AM
  4. wide character (unicode) and multi-byte character
    By George2 in forum Windows Programming
    Replies: 6
    Last Post: 05-05-2007, 12:46 AM
  5. pic movement
    By pode in forum Game Programming
    Replies: 31
    Last Post: 08-21-2002, 09:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21