• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How would one make a slide system?

Status
Not open for further replies.
To be more precise, a slide system with physics. Take Icegliders the map for example, you slide and when you try to turn you slide to the side hitting into stuff. You also bounce into people to try to kill them for points, you bounce them and they bounce you.

The hardest part I am having is the curve equation/for sliding to the side when moving to a new point.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Notes:
acceleration can be set to anything, but keep it between 0.5 - 2.0 or so.
friction must be between 0.00 and 1.00, but recommended you stay between 0.85 and 0.99.

The trigger:
  • Slide Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in sliders and do (Actions)
        • Loop - Actions
          • Set tunit = (Picked unit)
          • Set tid = (Custom value of tunit)
          • -------- move unit --------
          • Custom script: call SetUnitX(udg_tunit, GetUnitX(udg_tunit) + udg_dx[udg_tid])
          • Custom script: call SetUnitY(udg_tunit, GetUnitY(udg_tunit) + udg_dy[udg_tid])
          • -------- perform acceleration --------
          • Set dx[tid] = (dx[tid] + (acceleration x (Cos((Facing of tunit)))))
          • Set dy[tid] = (dy[tid] + (acceleration x (Sin((Facing of tunit)))))
          • -------- apply friction --------
          • Set dx[tid] = (dx[tid] x friction)
          • Set dy[tid] = (dy[tid] x friction)
(using a unit indexing system, not necessary if you only have 1 slider per player)

For collisions, you just accelerate them away from each other, using a higher acceleration.
Set dx[tid] = (dx[tid] + (collisionacceleration x (Cos((angle between units)))))
Set dy[tid] = (dy[tid] + (collisionacceleration x (Sin((angle between units)))))
(and do the same for the other unit, turning it around)

EDIT: If you want more control over the acceleration and friction, you could make a new looping trigger for that with a slower period.
Friction reduces the speed by a factor. This means that eventually the speed loss due to friction is equal to the acceleration, causing a "natural" top speed.
 

Attachments

  • componentsliding.w3x
    22.6 KB · Views: 83
Status
Not open for further replies.
Top