| 06-10-2009, 11:44 PM | #1 |
I currently map a naval map with a simple 2d projectile system which ignores the height. It looks good as long the terrain is flat, but that makes the terrain dull... Also when traveling over land it look silly when the projectile is also climbing height... ...So I wonder how I add a height detection, or enforcing the projectile to keep the same height while traveling instead of going up and down in terrain with different elevation? I'm asking this cuz it's beyond my current editor knowledge. Must I make a new system and engine, or can it be done few conditions? Current 2d movement trigger JASS:function Trig_Unit_Move_Code_Enum takes nothing returns nothing local unit u = GetEnumUnit() call SetUnitPosition(u, GetUnitX(u)+27.0*Cos(GetUnitFacing(u)*0.01745), GetUnitY(u)+27.0*Sin(GetUnitFacing(u)*0.01745)) set u = null endfunction function Trig_Unit_Move_Code_Enum_Fast takes nothing returns nothing local unit u = GetEnumUnit() call SetUnitPosition(u, GetUnitX(u)+36.0*Cos(GetUnitFacing(u)*0.01745), GetUnitY(u)+36.0*Sin(GetUnitFacing(u)*0.01745)) set u = null endfunction function Trig_Unit_Move_Code_Enum_Slow takes nothing returns nothing local unit u = GetEnumUnit() call SetUnitPosition(u, GetUnitX(u)+18.0*Cos(GetUnitFacing(u)*0.01745), GetUnitY(u)+18.0*Sin(GetUnitFacing(u)*0.01745)) set u = null endfunction function Trig_Unit_Move_Code_Actions takes nothing returns nothing call ForGroup(udg_Move, function Trig_Unit_Move_Code_Enum) call ForGroup(udg_MoveFast, function Trig_Unit_Move_Code_Enum_Fast) call ForGroup(udg_MoveSlow, function Trig_Unit_Move_Code_Enum_Slow) endfunction //=========================================================================== function InitTrig_Unit_Move_Code takes nothing returns nothing set gg_trg_Unit_Move_Code = CreateTrigger() call TriggerAddAction(gg_trg_Unit_Move_Code, function Trig_Unit_Move_Code_Actions) call TriggerRegisterTimerEvent(gg_trg_Unit_Move_Code, 0.03, true) endfunction |
| 06-11-2009, 03:29 AM | #2 |
looks like you need a projectile system for this, like store the initial terrain height of the projectile unit, after some time while the projectile is running, see if the terrain height is the same as the stored height, if it is lower, then do some stuffs to still maintain the initial height of the projectile, if the now terrain height is higher than the initial one, do something with the projectile unit I suggest some kind of vector projectile system, try projectile system found in the resource section, or if you want to create your own projectile system with the use of vectors, vector (system?) will greatly help you. |
| 06-11-2009, 02:05 PM | #3 | |
I posted the 2d projectile system in my first post now. And yes that's all there is. Simple and good. Simply put projectiles are units in unit groups which moves every 0.03 seconds in their facing direction. A different trigger deals with the creation of projectiles, but that's not important here. Quote:
Can you give me an short example? Is it possible to store terrain heights in variables? |
| 06-13-2009, 02:32 PM | #4 |
local real h = GetUnitFlyHeight(projectile) ? |
