I want to add a realistic physics mechanic to one or two of my maps where units slow down when moving uphill. I am also interested in the reverse, making them move faster when moving downhill.
It would make sense to have different movement speeds depending on how steep the terrain is.
I have no idea where to begin or if it's possible - I think it might be. And how much will it lag per unit - is it feasible on mass scale?
The best idea I can form is a trigger that constantly checks a unit's z position (once every second would be more than plenty for wide scale) and modifies it's movement speed with a buff over the next second or so.
-
One of the maps I want to implement this in is a mass-scale siege-style warfare map (tower on hill = hard to attack).
But the other map is much smaller scale, perhaps 8 units on the map that need this effect (1 per player). This is going to be a racing map with hopefully a real engine mechanic where you start off slow and accelerate - perhaps this uphill/downhill physics effect can be tied into the momentum speed mechanic? This one might need to be calculated quite frequently.
I guess I'm not really asking for step by step instructions. I just want to know if its possible and if it will lag, and maybe a few thoughts/hints.
dynamic moverment speed
Events
Timer - Every 0.1 seconds of Real Time
Local Variables
tmp point = No Point <Point>
current height = 0.0 <Real>
next height = 0.0 <Real>
movement speed multiplier = 0.0 <Real>
factor = 4.0 <Real (Constant)>
Conditions
Actions
Unit Group - Pick each unit in (Any units in (Entire map) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
Actions
Variable - Set tmp point = (Position of (Picked unit))
Variable - Set current height = (Ground height at tmp point)
Variable - Set next height = (Ground height at (tmp point offset by 0.1 towards (Facing of (Picked unit)) degrees))
Variable - Set movement speed multiplier = (1.0 + ((current height - next height) * factor))
Unit - Set (Picked unit) Base Movement Speed to (((Picked unit) Base Movement Speed (Default)) * movement speed multiplier)
It wont cause any problems except you have ALOT of units on the map (like 100+).
You might tweak this a little bit by changing the interval and the offset of the next height point (smaller intervall & smaller offset make it more accurate).
Also you might change the factor variable to your needs. It just makes the movement speed change more noticeable, depending on how much you need.
I want to add a realistic physics mechanic to one or two of my maps where units slow down when moving uphill. I am also interested in the reverse, making them move faster when moving downhill.
It would make sense to have different movement speeds depending on how steep the terrain is.
I have no idea where to begin or if it's possible - I think it might be. And how much will it lag per unit - is it feasible on mass scale?
The best idea I can form is a trigger that constantly checks a unit's z position (once every second would be more than plenty for wide scale) and modifies it's movement speed with a buff over the next second or so.
-One of the maps I want to implement this in is a mass-scale siege-style warfare map (tower on hill = hard to attack).
But the other map is much smaller scale, perhaps 8 units on the map that need this effect (1 per player). This is going to be a racing map with hopefully a real engine mechanic where you start off slow and accelerate - perhaps this uphill/downhill physics effect can be tied into the momentum speed mechanic? This one might need to be calculated quite frequently.
I guess I'm not really asking for step by step instructions. I just want to know if its possible and if it will lag, and maybe a few thoughts/hints.
dynamic moverment speed
Events
Timer - Every 0.1 seconds of Real Time
Local Variables
tmp point = No Point <Point>
current height = 0.0 <Real>
next height = 0.0 <Real>
movement speed multiplier = 0.0 <Real>
factor = 4.0 <Real (Constant)>
Conditions
Actions
Unit Group - Pick each unit in (Any units in (Entire map) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
Actions
Variable - Set tmp point = (Position of (Picked unit))
Variable - Set current height = (Ground height at tmp point)
Variable - Set next height = (Ground height at (tmp point offset by 0.1 towards (Facing of (Picked unit)) degrees))
Variable - Set movement speed multiplier = (1.0 + ((current height - next height) * factor))
Unit - Set (Picked unit) Base Movement Speed to (((Picked unit) Base Movement Speed (Default)) * movement speed multiplier)
It wont cause any problems except you have ALOT of units on the map (like 100+).
You might tweak this a little bit by changing the interval and the offset of the next height point (smaller intervall & smaller offset make it more accurate).
Also you might change the factor variable to your needs. It just makes the movement speed change more noticeable, depending on how much you need.
Thank you very much this is precisely the kind of thing I was looking for to study!