Ice and Sliding Players

By LadylexUK

There was an enquiry how to create a sliding on ice effect that is seen in Undertale. When the player hits an icy patch they are slid forward to the end of it.

We have various icy paints we can use to prettify our worlds but our players do not act as if they are on ice (they do not slide). Changing the friction on these materials does not work. After viewing Koding Konversations there were suggestions to use raycasting to detect the material then create some sliding kode – but strangely no-one posted a sliding kode, and the suggestions to use move or push were obscure and did not in practice actually work. However after some experimentation I have something that does work. Firstly it moves your player in a straight line only and your player will continue to slide until they are no longer on ice. Secondly I have use the alert emote – with experimentation with kinect you could possibly create a reasonable skating move for this – but you have no directional control when sliding in this kode, so you would need to change this for true skating.

You will need: player, logic cube (invisible), ice paint

Paint the area of ice to slide on (note the pallet number of the material you have used).

In player

  1. WHEN [raycast hit][in direction][world down]
  2. …WHEN [terrain material index][equal to][material slot 8] // or whatever slot you have used
  3. …/…WHEN [started to] DO [objvar:block][equals][create][iwp:logic cube][at position][position]
  4. …/…WHEN DO [boolvar:slide][equals][true]
  5. …/…WHEN DO [push][objvar:block][in direction][forward]
  6. WHEN [terrain material index][not equal to][material slot 8]
  7. …WHEN DO [jump height][equals][0]
  8. …WHEN [started to] DO [jump] //this stops the emote immediately and the jump height means it is not detectable as a jump
  9. …WHEN DO [boolvar:slide][equals][false]
  10. …WHEN DO [objvar:block][boolvar:slide][equals][false]
  11. …/…WHEN DO [jump height][equals][2] // standard jump height
  12. WHEN [boolvar: slide]
  13. …WHEN DO [emote][alert] // you could make a custom emote here

The logic cube

  1. WHEN DO [forward][equals][creator][forward]
  2. WHEN [once] DO [attach][creator][to socket][center]
  3. …WHEN DO [boolvar:slide][equals][true]
  4. WHEN [not][boolvar:slide]
  5. …WHEN DO [detach][creator]
  6. …WHEN DO [destroy][me]

 

Comments are closed.

Powered by WordPress.com.

Up ↑

%d bloggers like this: