3d projectiles?

jrhetf4xb

Member
Reaction score
12
It has been bugging me for a while but why don't most projectile systems offer 3d collision detection as well? The way I imagine it is like a simple check with GetUnitFlyHeight() (of course combined with a normal XY group enum), something like:

Code:
if (RAbsBJ(GetUnitFlyHeight(collidedTarget) - GetUnitFlyHeight(projectile)) <= PROJECTILE_RADIUS) then 
    //... all that stuff

Or maybe I'm missing something?
 

SerraAvenger

Cuz I can
Reaction score
234
It has been bugging me for a while but why don't most projectile systems offer 3d collision detection as well? The way I imagine it is like a simple check with GetUnitFlyHeight() (of course combined with a normal XY group enum), something like:

Code:
if (RAbsBJ(GetUnitFlyHeight(collidedTarget) - GetUnitFlyHeight(projectile)) <= PROJECTILE_RADIUS) then 
    //... all that stuff

Or maybe I'm missing something?

Please print GetUnitFlyHeight of flying units to the screen. Then also raise the terrain upon which the unit is standing and print GetUnitFlyHeight of that to the screen.

I guess the main problem lies somewhere around this. I haven't used Wc3 for ages, so I can't really tell.

IIRC, Azlier made some nice scripts to figure out the real z coordinate of a unit. Dunno, though.
 

Trollvottel

never aging title
Reaction score
262
There some points you forgot.
1. The thing SerraAvenger mentioned: If there are different terrain heights, there will be different z-heights of units that have the same flying height.
the Z-height is just flying height of unit + GetLocationZ at it's position.

2. You cant calculate the distance like this. If you do it like this, you will get a cube in which you pick the units and not a sphere.

Do it like this:

Pick units in Radius PROJECTILE_RADIUS at position X,Y
Now use pythagoras (pseudocode):

If ((projectileX-collidedTargetX)² + (projectileY-collidedTargetY)² + (projectileZ-collidedTargetZ)² <= PROJECTILE_RADIUS) then
Do all that stuff
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
>It has been bugging me for a while but why don't most projectile systems offer 3d collision detection as well?

Which systems are you referring?

One thing no system has is 3d collision of units to destructables due to no GetDestructableZ =/.


OT: What was the better way of doing collisions The GroupEnumUnitsInRange or with a Rect entering event? One of them wasn't suitable for very high speed projectiles but I forgot which one.
 

jrhetf4xb

Member
Reaction score
12
Yes, terrain height would definitely be included but it was a quick example.
And I have no idea (my math level being low also included :p). how Pythagoras theorem would have anything to do with spherical shapes...

> Which systems are you referring?
All submitted?

> One thing no system has is 3d collision of units to destructables due to no GetDestructableZ =/.
Meh, unit to unit has a chance to be used more :)
 

Trollvottel

never aging title
Reaction score
262
K, image example following.
hope you understand it.


lol, drnk on teh internetz

/edit: the center of the point is your object. the square on is the one with which you check collision.

/€²: There is a mistake in the image. in the left circle the square should be closer to the center so that it seems to be in range (so it is in the circle).
 

Attachments

  • Neu Bitmap.JPG
    Neu Bitmap.JPG
    27.8 KB · Views: 314

Accname

2D-Graphics enthusiast
Reaction score
1,462
you should also keep in mind the wc3 engine auto-adjusts flying heights of flying units when they come close to cliffs. between 2 cliff levels the flying height of the unit will not be equal to the actual height in which it is displayed on the screen.
 

jrhetf4xb

Member
Reaction score
12
^ Wouldn't that affect the dummy units (projectiles) as well?

I'm not sure I quite understand but from the calculations it seems that (looking at the right image):
d should be less than r so that the projectile can collide, right?
 

Trollvottel

never aging title
Reaction score
262
jop, thats right. and for that you need my calculations. your calculations would pick units in a cylinder (i drew the square in which you picked the units).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top