wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 12-31-2009, 12:25 PM   #1
Na_Dann_Ma_GoGo
User
 
Join Date: Feb 2008
Posts: 125

Na_Dann_Ma_GoGo has little to show at this moment (8)

Default Physics regarding units correctly bouncing of walls

Hi there,
I'm really struggling with making units bounce from e.g. walls (in general places with higher terrain height (z)).
I know that the angle of incidence equals the angle of reflexion. However I need to "convert" those angles to the ones Wc3 uses (math. unit circle).

Or easier, overall, how do I bounce units physically correct in Wc3? How do I detect when they bounce ( periodically z-height detection around the units? (collision?)) and what the angle will be?

I'm completely stuck there and think I do something basically wrong.

Edit: As an example. A unit flies towards a horizontal wall with an angle of 10 in Wc3. I know it'll bounce of with a 350.
But I've yet to find a formula that works for all angles and all differently angled walls.

Last edited by Na_Dann_Ma_GoGo : 12-31-2009 at 12:32 PM.
Na_Dann_Ma_GoGo is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 12-31-2009, 12:32 PM   #2
Tot
6
 
Tot's Avatar
 
Join Date: Oct 2008
Posts: 841

Tot will become famous soon enough (53)Tot will become famous soon enough (53)

Default

are your walls only higher terrain or also doodads? are you useing blizz movement-system?
__________________
Current Projects:
  • Masters Of WarCraft: Some mixture of AoS and RPG
    Terrain: 100%, Coding: 75%, Heroes: 0%, Items: 0%, Creeps: 0%, Upgrades: 0%
  • hunting emos
____________________________________
scheiss kack dreck sausacksau bundeswehr
Tot is offline   Reply With Quote
Old 12-31-2009, 01:11 PM   #3
DioD
obey
 
DioD's Avatar
 
Join Date: Feb 2006
Posts: 1,532

Submissions (4)

DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)

Send a message via ICQ to DioD
Default

check vector system in resource section.
DioD is offline   Reply With Quote
Old 12-31-2009, 01:30 PM   #4
Na_Dann_Ma_GoGo
User
 
Join Date: Feb 2008
Posts: 125

Na_Dann_Ma_GoGo has little to show at this moment (8)

Default

Quote:
Originally Posted by Tot
are your walls only higher terrain or also doodads? are you useing blizz movement-system?

Currently rather higher terrain as I guess doodads do need extra processing power? Not sure what you mean about blizz moving-system though.

@ DioD gonna do that.
Na_Dann_Ma_GoGo is offline   Reply With Quote
Old 12-31-2009, 01:43 PM   #5
Tot
6
 
Tot's Avatar
 
Join Date: Oct 2008
Posts: 841

Tot will become famous soon enough (53)Tot will become famous soon enough (53)

Default

blizz moving system: non-triggered moving of things

if your using your own movement system:
check the terrain level with GetTerrainCliffLevel takes real x, real y returns integer at start and endpoint. If it's different, then calculate the distance between these 2 points and get the point at which the level changes. Now youre calculating the dist to this point from the start and substract it from the overall distance. Now you calculate the impact angle and do
Collapse JASS:
call SetUnitX(u,BouncePointX+Cos(BounceAngle)*SubstractDistance)
call SetUnitY(u,BouncePointY+Sin(BounceAngle)*SubstractDistance)

and check again with the bouncePoint as start and the calculated point as end.
__________________
Current Projects:
  • Masters Of WarCraft: Some mixture of AoS and RPG
    Terrain: 100%, Coding: 75%, Heroes: 0%, Items: 0%, Creeps: 0%, Upgrades: 0%
  • hunting emos
____________________________________
scheiss kack dreck sausacksau bundeswehr
Tot is offline   Reply With Quote
Old 12-31-2009, 01:57 PM   #6
Na_Dann_Ma_GoGo
User
 
Join Date: Feb 2008
Posts: 125

Na_Dann_Ma_GoGo has little to show at this moment (8)

Default

Quote:
Originally Posted by Tot
blizz moving system: non-triggered moving of things

if your using your own movement system:
check the terrain level with GetTerrainCliffLevel takes real x, real y returns integer at start and endpoint. If it's different, then calculate the distance between these 2 points and get the point at which the level changes. Now youre calculating the dist to this point from the start and substract it from the overall distance. Now you calculate the impact angle and do
Collapse JASS:
call SetUnitX(u,BouncePointX+Cos(BounceAngle)*SubstractDistance)
call SetUnitY(u,BouncePointY+Sin(BounceAngle)*SubstractDistance)

and check again with the bouncePoint as start and the calculated point as end.

Well I use a triggered movement system of my own.
And I totally get your idea behind this thought I rather use
Collapse JASS:
call MoveLocation(LOC,targ_x,targ_y)
if GetLocationZ(LOC)-.current_z >= 40 then ...
as I thought the clff level is.. well the cliff level and not the terrain height?

But my real problem is this:
Quote:
Now you calculate the impact angle
How shall I do it, especially when I don't even know the obstacles normal (if hope that's the real term). And regarding that normal the impact angle changes...
Na_Dann_Ma_GoGo is offline   Reply With Quote
Old 12-31-2009, 02:16 PM   #7
Tot
6
 
Tot's Avatar
 
Join Date: Oct 2008
Posts: 841

Tot will become famous soon enough (53)Tot will become famous soon enough (53)

Default

the impact angle is always 0<=impact angle<=90 and he can be calculated via: direction of the wall (either 0 or 90[180, 270 and 360 are not needed, cause 180, 360 is 0 and 270 is 90 (direction of the wall is unimportant)]) - facing of the impacting unit
-->
Collapse JASS:
function GetImpactAngle takes real wallAngle, unit u returns real
local real impactAngle=wallAngle-GetUnitFacing(u)
if impactAngle<0 then
     set impactAngle=-impactAngle
endif
if impactAngle>2*bj_PI then
    set impactAngle=ModuloReal(impactAngle,2*bj_PI)
endif
if impactAngle>0.5*bj_PI and impactAngle<=bj_PI then //wc3 is calculating with radiansnot with degrees
    set impactAngle=impactAngle-0.5*bj_PI
elseif impactAngle>bj_PI and impactAngle<=1.5*bj_PI then
    set impactAngle=impactAngle-bj_PI
elseif impactAngle>1.5*bj_PI and impactAngle<=2*bj_PI then
    set impactAngle=impactAngle-1.5*bj_PI
endif

to get the walls angle, check one point on the left and one on the right side of your impact point and compare the height, if it's equal the angle is 0, otherwise it's 90
__________________
Current Projects:
  • Masters Of WarCraft: Some mixture of AoS and RPG
    Terrain: 100%, Coding: 75%, Heroes: 0%, Items: 0%, Creeps: 0%, Upgrades: 0%
  • hunting emos
____________________________________
scheiss kack dreck sausacksau bundeswehr
Tot is offline   Reply With Quote
Old 12-31-2009, 02:36 PM   #8
Na_Dann_Ma_GoGo
User
 
Join Date: Feb 2008
Posts: 125

Na_Dann_Ma_GoGo has little to show at this moment (8)

Default

I kinda got to this point more or less already, what I'm really searching for a is a formula to use instead of the "if, elseif, ..." stuff. That also should work for walls of all angles and not just straight horizontal / vertical ones.

Edit: Also I still don't know how get from the impactAngle to the new bounceAngle (new Unit movement/facing direction), as that one ranges from 0 to 2 PI.

Last edited by Na_Dann_Ma_GoGo : 12-31-2009 at 03:15 PM.
Na_Dann_Ma_GoGo is offline   Reply With Quote
Old 01-01-2010, 01:06 AM   #9
Switch33
User
 
Join Date: Oct 2003
Posts: 150

Switch33 is on a distinguished road (13)

Default

http://www.thehelper.net/forums/showthread.php?t=124461
Switch33 is offline   Reply With Quote
Old 01-01-2010, 12:45 PM   #10
Na_Dann_Ma_GoGo
User
 
Join Date: Feb 2008
Posts: 125

Na_Dann_Ma_GoGo has little to show at this moment (8)

Default

Ah thanks that's really helpful!
Na_Dann_Ma_GoGo is offline   Reply With Quote
Old 01-01-2010, 08:47 PM   #11
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,186

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

I find doing this with angles rather cumbersome and only worth it if your "physics" are meant to be oversimplified (for example, if the walls are allowed to only face four directions) for gameplay reasons. Otherwise, I find a general vector solution much more practical.
__________________
Anitarf is offline   Reply With Quote
Old 01-01-2010, 09:27 PM   #12
Na_Dann_Ma_GoGo
User
 
Join Date: Feb 2008
Posts: 125

Na_Dann_Ma_GoGo has little to show at this moment (8)

Default

Hmm yah. For now I got the oversimpliefied version ;)
I may switch to vectors. But that depends.
Working with vectors doesn't really change THAT much or? I guess I just need to do all the SetUnitX() SetUnitY() stuff with the x/y vector parts and the fly height with the z part. And on collision and so I do add / subtract and all that stuff? I did have vectors half a year ago at school but I dunno how working with them in Wc3 ist^^
Na_Dann_Ma_GoGo is offline   Reply With Quote
Old 01-02-2010, 08:04 PM   #13
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,186

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Well, it depends on how exactly you want your physics to function, but a simple bouncing sample is included in the vector system test map.
__________________
Anitarf is offline   Reply With Quote
Old 01-03-2010, 10:17 AM   #14
Na_Dann_Ma_GoGo
User
 
Join Date: Feb 2008
Posts: 125

Na_Dann_Ma_GoGo has little to show at this moment (8)

Default

Hmm that's indeed pretty cool.
I really consider switching to this however... how would you deal with bouncing off from doodads? I guess there's nothing like this implanted. But in my maps walls may be made of doodads and not terrain all the time. And you cannot manipulate the terrain in a way that it fits the doodads size etc. and is even hidden by the doodad.
Na_Dann_Ma_GoGo is offline   Reply With Quote
Old 01-03-2010, 12:07 PM   #15
Viikuna-
User
 
Viikuna-'s Avatar
 
Join Date: Feb 2009
Posts: 203

Viikuna- will become famous soon enough (44)Viikuna- will become famous soon enough (44)

Default

Use destructibles instead of doodads and attach all the needed data to them with some hashtables, so when you pick a destructible which is in way of your projectile, you can get its height and length and other thingies like that are needed to calculate a nice and smooth collinsion.

You can make destructibles untargettable, so they look exactly like doodads, this is no problem.
__________________
No Marlo, no game.
Viikuna- is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 09:36 PM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2018, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services