• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Gravity, Terrain Detect, and Sliding problem

Status
Not open for further replies.
Level 3
Joined
Oct 28, 2008
Messages
27
Hi, I'm creating a fake gravity that pulls the units in a southward direction on the map. It works just fine, but when they hit raised terrain instead of stopping, they slide to the right. I am assuming this is because I am using an instant move trigger and it resorts to moving the unit to the closest place it can if it can't go down. I tried adding a condition that checked whether the unit was on a cliff or dirt terrain to stop its movement, but it didn't change anything. Any suggestions?

I tried making Location[4] at a point a little lower than the unit, as Location[3] is where the unit is, and Location[2] is where the unit is being moved. Maybe a getlocationZ would be better, but I don't know how to implement...
Additionally, the unit is a hover. Changing to fly just makes it pass over everything, but maybe something useful can be used by knowing this.

  • gravy test
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Set Location[4] = (Location[3] offset by (0.00, -30.00))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DownTrue Equal to False
          • UpTrue Equal to False
          • LeftTrue Equal to False
          • RightTrue Equal to False
          • (Terrain type at Location[4]) Equal to Lordaeron Summer - Dirt
        • Then - Actions
          • Set Location[2] = ((Position of Unit) offset by 30.00 towards 270.00 degrees)
          • Unit - Move Unit instantly to Location[2]
          • Custom script: call RemoveLocation(udg_Location[2])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Speed Less than 3.00
            • Then - Actions
              • Set Speed = (Speed + 0.02)
              • Set AnimationSpeed = (AnimationSpeed + 0.01)
            • Else - Actions
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Location[4])
 
Last edited:
Level 18
Joined
Aug 23, 2008
Messages
2,319
First of all: use the
  • tags and copy your trigger between those tags by using the Copy as Text feature of the World Editor.
  • Second of all: With Location[4], you're going 30 to the south. You're doing exactly the same with location[2], which is probably causing your 'slide' problem. To solve this, you should make the unit flying and change his flying height to 'current flying height - 30'.
 
Level 3
Joined
Oct 28, 2008
Messages
27
K, i'll change out the trigger img.
However I do want to make the unit move south. Flying height doesn't come into this. I've made a bird's eye view camera and have the unit rotated so it looks like he walks on the cliff edge.
footyoo9.jpg

I haven't noticed any difference between switching between Location[2] and Location[3] for detecting the terrain beneath the unit. I just want to be able to make him stop moving if he is 'on top of' a cliff face. With Location[4] I thought that maybe because the unit can't ever actually go on top of the cliff face, I should detect slightly to the south of him, but this didn't benefit me.
 
Level 3
Joined
Oct 28, 2008
Messages
27
Thx! That's a better direction to take. I changed it to this, but it still has the sliding motion problem.
  • gravy test Copy
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DownTrue Equal to False
          • UpTrue Equal to False
          • LeftTrue Equal to False
          • RightTrue Equal to False
          • (Terrain pathing at Location[2] of type Walkability is off) Equal to False
        • Then - Actions
          • Set Location[2] = ((Position of Unit) offset by 30.00 towards 270.00 degrees)
          • Unit - Move Unit instantly to Location[2]
          • Custom script: call RemoveLocation(udg_Location[2])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Speed Less than 3.00
            • Then - Actions
              • Set Speed = (Speed + 0.02)
              • Set AnimationSpeed = (AnimationSpeed + 0.01)
            • Else - Actions
        • Else - Actions
i attached a version of the game if anyone would like to see...
 

Attachments

  • 2D Game.w3x
    41.6 KB · Views: 92
Last edited:
Level 40
Joined
Dec 14, 2005
Messages
10,532
Since we can assume that all raised terrain is a platform, and all pathable is a constant height (which is a reasonable assumption for a 2 dimensional game). Next assume all platforms 'stick out of the screen,' so to speak, in that they are higher in the hidden third dimension than the base terrain. we can therefore assume:

terrainDepth(pathable) = x
terrainDepth(unpathable) > x
GetLocationZ(someLoc) = terrain height at someLoc

if GetLocationZ(someLoc) - x > 1 then //leave some room for uncertainty
//your area is unpathable: halt

Therefore, the following code can be implemented. Assume base terrain height is 0 (change as necessary by adding -baseTerrainHeight, where baseTerrainHeight is your base terrain height).

(Uses Real variable ZHeight)

  • Actions
    • -------- set up someLoc --------
    • Custom script: set udg_ZHeight = GetLocationZ(udg_someLoc)
    • If (All Conditions are True) ...
      • If - Conditions
        • ZHeight Less Than or Equal to 1.00
      • Then - Actions
        • -------- Cause unit to fall --------
      • Else - Actions
        • -------- Set vertical velocity to 0 --------
    • -------- Update horizontal and vertical positions --------
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
The main problem with your method is not speed, but error; it's hard to leave unnoticed holes in a cliff, but it's easy to leave unnoticed holes in a pathing map.

On that note, rather than setting the vertical velocity to 0 with my method, you should decrease it by a factor, so as to make sure the unit exactly lands on the terrain.
 
Status
Not open for further replies.
Top