ID:2117467
 
I am trying to make it so that when a player presses a button their icon or (body) phases into the ground. I already had the idea of using pixel_y to simulate them going down, but I could not figure out a way to make it so that their body slowly goes down. I tried to make a black object that has an animation of it going up so that I could make a code that turns that object's icon into the turf icon of wherever the player is standing, but it ended up crashing the game.

Code:
mob
verb
Phase()
for(var/turf/T in usr.loc)
var/obj/Phasing_Icon/P = new /obj/Phasing_Icon
P.loc = usr.loc
P.icon = T.icon


Did you try using animate()?
Yes that was my first attempt.
So you tried something similar to the following?

// pixel_x/y need some adjusting for your own project.
var/obj/phaser = new/obj {alpha = 92; pixel_y = -16; layer = MOB_LAYER + 0.1} (loc)
phaser.icon = loc.icon
var/animation_time = 10
animate(phaser, alpha = 255, color = "#000", pixel_y = 16, time = animation_time)
sleep(animation_time)
phaser.loc = null
I tried something similar to that, but the object never turned the same icon as the turf.
In response to Dayvon64
It worked fine for me in my test project.

One thing I noticed wrong with your snippet:
for(var/turf/T in usr.loc)


You are looking for turfs inside usr.loc, which is likely a turf. This is probably why your object did not take on the turf's icon -- nothing was found.

You don't even need a for() loop there. Just use usr.loc for your turf reference.
Oh, alright now it worked. Thank you