How to warp/distort a 2D sprite?


I was wondering if it is possible to distort a 2D sprite by code. What I mean by that is to make the following distortion possible:


In other words, I am searching for a way to distort an image in “real time” by code. Is it possible?

Thank you

If it must be a sprite, then the typical way this “distortion” is accomplished is to create a series of frames that form an animation. The frames are played, forming an animation of the bending. In Unity, there are a variety of ways to “bend” a texture. Without more context, we cannot suggest which is right for you. Here are some ways beyond the sprite animation suggestion:

  1. Animate a sprite sheet on a quad
  2. Move the vertices of a mesh (procedural mesh)
  3. Write a shader for the distortion
  4. Change the uv coordinates applied to each triangle in a mesh
  5. Skinned mesh renderer
  6. Building the visual out of multiple game objects and moving the objects through code or an animation