Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. [edited] collision response in a RTS

[edited] collision response in a RTS

Scheduled Pinned Locked Moved C / C++ / MFC
question
9 Posts 2 Posters 38 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Calin Negru
    wrote on last edited by
    #1

    I have changed my mind about what I want to ask. I’m not interested in groups anymore. How do you solve units colliding at all? If it’s just two units is it about where the two units have been ( last visited node ) and where they are traveling towards? Also what if a unit collides with more than one unit in a short amount of time?

    L 2 Replies Last reply
    0
    • C Calin Negru

      I have changed my mind about what I want to ask. I’m not interested in groups anymore. How do you solve units colliding at all? If it’s just two units is it about where the two units have been ( last visited node ) and where they are traveling towards? Also what if a unit collides with more than one unit in a short amount of time?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Hi, It sounds like you just need a push in the right direction. Have a look at the Flow Field family of algorithms. [Flow field algorithm](https://www.google.com/search?q=flow+field+algorithm) Did you have a C++ related question to ask?

      C 1 Reply Last reply
      0
      • L Lost User

        Hi, It sounds like you just need a push in the right direction. Have a look at the Flow Field family of algorithms. [Flow field algorithm](https://www.google.com/search?q=flow+field+algorithm) Did you have a C++ related question to ask?

        C Offline
        C Offline
        Calin Negru
        wrote on last edited by
        #3

        Thanks for advice

        L 1 Reply Last reply
        0
        • C Calin Negru

          Thanks for advice

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Randor wrote:

          It sounds like you just need a push in the right direction.

          Heh, I thought the paronomasian response was clever but I doubt anyone noticed. :-D

          1 Reply Last reply
          0
          • C Calin Negru

            I have changed my mind about what I want to ask. I’m not interested in groups anymore. How do you solve units colliding at all? If it’s just two units is it about where the two units have been ( last visited node ) and where they are traveling towards? Also what if a unit collides with more than one unit in a short amount of time?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Every move requires distance and direction (target point; angle). Prior to the actual move, one checks for any units that will be "intersected" by moving to that point. Rectangles have position and size. Rectangles collide when they interest. (Unless rotated, then you need to deal with polygons) (The actual move is then shortened so you don't "pass through" the target). The "mover" then is obviously the attacker; the other the defender. If both moving, it was attacking and counter-attaching. The result of a "charge" is a melee or a repulse; followed by a pursuit. There are no "simultaneous" collisions. Any subsquent collisions creates another attacker-defender scenario. And infantry won't pursue other infantry; they fire them down. Cavalry will run down (dispersed) infantry. Cavalry can not be expected to pursue (and catch) other cavalry. Artillery is unable to "run" without limbering up.

            "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

            C 1 Reply Last reply
            0
            • L Lost User

              Every move requires distance and direction (target point; angle). Prior to the actual move, one checks for any units that will be "intersected" by moving to that point. Rectangles have position and size. Rectangles collide when they interest. (Unless rotated, then you need to deal with polygons) (The actual move is then shortened so you don't "pass through" the target). The "mover" then is obviously the attacker; the other the defender. If both moving, it was attacking and counter-attaching. The result of a "charge" is a melee or a repulse; followed by a pursuit. There are no "simultaneous" collisions. Any subsquent collisions creates another attacker-defender scenario. And infantry won't pursue other infantry; they fire them down. Cavalry will run down (dispersed) infantry. Cavalry can not be expected to pursue (and catch) other cavalry. Artillery is unable to "run" without limbering up.

              "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

              C Offline
              C Offline
              Calin Negru
              wrote on last edited by
              #6

              My guess is there is more than one way to solve the problem. Age of Empires version 1 for instance had some issues when a unit was caught between two other units, a problem Warcraft 3 didn’t have.

              L 1 Reply Last reply
              0
              • C Calin Negru

                My guess is there is more than one way to solve the problem. Age of Empires version 1 for instance had some issues when a unit was caught between two other units, a problem Warcraft 3 didn’t have.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                It's all in the "detecting". Collision detection involves enemies AND friendlies. Is the collision a "blocking" situation, or a "merge" in terms of hand to hand. What you're refering to are "bugs": "trapped" sprites. Regarding "group collisions": in the some "systems", any party "within a minute", is considered party to the "collision" / conflict; i.e. 100 yds for infantry, 300 yds for cavalry.

                "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

                C 1 Reply Last reply
                0
                • L Lost User

                  It's all in the "detecting". Collision detection involves enemies AND friendlies. Is the collision a "blocking" situation, or a "merge" in terms of hand to hand. What you're refering to are "bugs": "trapped" sprites. Regarding "group collisions": in the some "systems", any party "within a minute", is considered party to the "collision" / conflict; i.e. 100 yds for infantry, 300 yds for cavalry.

                  "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

                  C Offline
                  C Offline
                  Calin Negru
                  wrote on last edited by
                  #8

                  Thanks for your comments Gerry

                  L 1 Reply Last reply
                  0
                  • C Calin Negru

                    Thanks for your comments Gerry

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    You're welcome!

                    "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups