Skip to main content
edited body
Source Link

Without stepping in and altering the algorithm itself, you could just stick with option B.

Calculating corrections won't be optimized anyway, and most probably you'll have to define ad hoc routines for each type/size of unit you're going to use.

Another thing to take into account is a possible collision detection implementation: The very idea of 'hugging' a wall with a vehicle can be (sort of) easily solved that way, even more if you won't care for vertical movement collisions since you'll be just working with a 2D world at that point. Even more easy and fast if you also don't care for a high level of precision with collisions (i.e: every unit is a circle with a defined radius).

Edit:

If you need a generic explanation on collision detection just search for any tutorial (or this website), there's plenty online.

If you mean in this specific case instead, once you obtain the path from your algorithm, just make the unit follow the path, and have the collision detection do its job once the unit actually tries to pass through any surface that you defined as a surface to check.

I.E: If you define your tank unit aaas a circle (A is the center, R is the radius) for the collision detection, once it's following a path that would be correct for infantry, the collision detection will prevent the tank from passing through (partially or completely) the wall by checking if the point A (defining the center of said circle) is closer than distance R to the wall. The way you handle the result of the collision dependdepends entirely on what you want to do. The easiest way is to make the component of the movement that is perpendicular to the wall null, so it will 'slide' along, basically 'hugging' the wall.

I suggested this approach mainly because working with 2D bound shape is easy and fast.

Without stepping in and altering the algorithm itself, you could just stick with option B.

Calculating corrections won't be optimized anyway, and most probably you'll have to define ad hoc routines for each type/size of unit you're going to use.

Another thing to take into account is a possible collision detection implementation: The very idea of 'hugging' a wall with a vehicle can be (sort of) easily solved that way, even more if you won't care for vertical movement collisions since you'll be just working with a 2D world at that point. Even more easy and fast if you also don't care for a high level of precision with collisions (i.e: every unit is a circle with a defined radius).

Edit:

If you need a generic explanation on collision detection just search for any tutorial (or this website), there's plenty online.

If you mean in this specific case instead, once you obtain the path from your algorithm, just make the unit follow the path, and have the collision detection do its job once the unit actually tries to pass through any surface that you defined as a surface to check.

I.E: If you define your tank unit aa a circle (A is the center, R is the radius) for the collision detection, once it's following a path that would be correct for infantry, the collision detection will prevent the tank from passing through (partially or completely) the wall by checking if the point A (defining the center of said circle) is closer than distance R to the wall. The way you handle the collision depend entirely on what you want to do. The easiest way is to make the component of the movement that is perpendicular to the wall null, so it will 'slide' along, basically 'hugging' the wall.

I suggested this approach mainly because working with 2D bound shape is easy and fast.

Without stepping in and altering the algorithm itself, you could just stick with option B.

Calculating corrections won't be optimized anyway, and most probably you'll have to define ad hoc routines for each type/size of unit you're going to use.

Another thing to take into account is a possible collision detection implementation: The very idea of 'hugging' a wall with a vehicle can be (sort of) easily solved that way, even more if you won't care for vertical movement collisions since you'll be just working with a 2D world at that point. Even more easy and fast if you also don't care for a high level of precision with collisions (i.e: every unit is a circle with a defined radius).

Edit:

If you need a generic explanation on collision detection just search for any tutorial (or this website), there's plenty online.

If you mean in this specific case instead, once you obtain the path from your algorithm, just make the unit follow the path, and have the collision detection do its job once the unit actually tries to pass through any surface that you defined as a surface to check.

I.E: If you define your tank unit as a circle (A is the center, R is the radius) for the collision detection, once it's following a path that would be correct for infantry, the collision detection will prevent the tank from passing through (partially or completely) the wall by checking if the point A is closer than distance R to the wall. The way you handle the result of the collision depends entirely on what you want to do. The easiest way is to make the component of the movement that is perpendicular to the wall null, so it will 'slide' along, basically 'hugging' the wall.

I suggested this approach mainly because working with 2D bound shape is easy and fast.

added 1059 characters in body
Source Link

Without stepping in and altering the algorithm itself, you could just stick with option B.

Calculating corrections won't be optimized anyway, and most probably you'll have to define ad hoc routines for each type/size of unit you're going to use.

Another thing to take into account is a possible collision detection implementation: The very idea of 'hugging' a wall with a vehicle can be (sort of) easily solved that way, even more if you won't care for vertical movement collisions since you'll be just working with a 2D world at that point. Even more easy and fast if you also don't care for a high level of precision with collisions (i.e: every unit is a circle with a defined radius).

Edit:

If you need a generic explanation on collision detection just search for any tutorial (or this website), there's plenty online.

If you mean in this specific case instead, once you obtain the path from your algorithm, just make the unit follow the path, and have the collision detection do its job once the unit actually tries to pass through any surface that you defined as a surface to check.

I.E: If you define your tank unit aa a circle (A is the center, R is the radius) for the collision detection, once it's following a path that would be correct for infantry, the collision detection will prevent the tank from passing through (partially or completely) the wall by checking if the point A (defining the center of said circle) is closer than distance R to the wall. The way you handle the collision depend entirely on what you want to do. The easiest way is to make the component of the movement that is perpendicular to the wall null, so it will 'slide' along, basically 'hugging' the wall.

I suggested this approach mainly because working with 2D bound shape is easy and fast.

Without stepping in and altering the algorithm itself, you could just stick with option B.

Calculating corrections won't be optimized anyway, and most probably you'll have to define ad hoc routines for each type/size of unit you're going to use.

Another thing to take into account is a possible collision detection implementation: The very idea of 'hugging' a wall with a vehicle can be (sort of) easily solved that way, even more if you won't care for vertical movement collisions since you'll be just working with a 2D world at that point. Even more easy and fast if you also don't care for a high level of precision with collisions (i.e: every unit is a circle with a defined radius).

Without stepping in and altering the algorithm itself, you could just stick with option B.

Calculating corrections won't be optimized anyway, and most probably you'll have to define ad hoc routines for each type/size of unit you're going to use.

Another thing to take into account is a possible collision detection implementation: The very idea of 'hugging' a wall with a vehicle can be (sort of) easily solved that way, even more if you won't care for vertical movement collisions since you'll be just working with a 2D world at that point. Even more easy and fast if you also don't care for a high level of precision with collisions (i.e: every unit is a circle with a defined radius).

Edit:

If you need a generic explanation on collision detection just search for any tutorial (or this website), there's plenty online.

If you mean in this specific case instead, once you obtain the path from your algorithm, just make the unit follow the path, and have the collision detection do its job once the unit actually tries to pass through any surface that you defined as a surface to check.

I.E: If you define your tank unit aa a circle (A is the center, R is the radius) for the collision detection, once it's following a path that would be correct for infantry, the collision detection will prevent the tank from passing through (partially or completely) the wall by checking if the point A (defining the center of said circle) is closer than distance R to the wall. The way you handle the collision depend entirely on what you want to do. The easiest way is to make the component of the movement that is perpendicular to the wall null, so it will 'slide' along, basically 'hugging' the wall.

I suggested this approach mainly because working with 2D bound shape is easy and fast.

Source Link

Without stepping in and altering the algorithm itself, you could just stick with option B.

Calculating corrections won't be optimized anyway, and most probably you'll have to define ad hoc routines for each type/size of unit you're going to use.

Another thing to take into account is a possible collision detection implementation: The very idea of 'hugging' a wall with a vehicle can be (sort of) easily solved that way, even more if you won't care for vertical movement collisions since you'll be just working with a 2D world at that point. Even more easy and fast if you also don't care for a high level of precision with collisions (i.e: every unit is a circle with a defined radius).