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).
- WHEN [raycast hit][in direction][world down]
- …WHEN [terrain material index][equal to][material slot 8] // or whatever slot you have used
- …/…WHEN [started to] DO [objvar:block][equals][create][iwp:logic cube][at position][position]
- …/…WHEN DO [boolvar:slide][equals][true]
- …/…WHEN DO [push][objvar:block][in direction][forward]
- WHEN [terrain material index][not equal to][material slot 8]
- …WHEN DO [jump height][equals]
- …WHEN [started to] DO [jump] //this stops the emote immediately and the jump height means it is not detectable as a jump
- …WHEN DO [boolvar:slide][equals][false]
- …WHEN DO [objvar:block][boolvar:slide][equals][false]
- …/…WHEN DO [jump height][equals] // standard jump height
- WHEN [boolvar: slide]
- …WHEN DO [emote][alert] // you could make a custom emote here
The logic cube
- WHEN DO [forward][equals][creator][forward]
- WHEN [once] DO [attach][creator][to socket][center]
- …WHEN DO [boolvar:slide][equals][true]
- WHEN [not][boolvar:slide]
- …WHEN DO [detach][creator]
- …WHEN DO [destroy][me]