• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Montein · Jul 31, 2014 at 05:26 AM · spriteprogramming

How to warp/distort a 2D sprite?

Hello,

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:

alt text

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

Thank you

example.png (17.5 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by robertbu · Jul 31, 2014 at 05:25 PM

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

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Montein · Jul 31, 2014 at 08:47 PM 0
Share

Thank you robertbu! What I'm trying to accomplish is a dynamic animation - is for this reason that the distortion cannot be pre-animated. I'll investigate about using the procedural mesh. Thanks again

avatar image robertbu · Jul 31, 2014 at 09:30 PM 0
Share

Note that the animation does not have to be run like a video. That is, you can drive the frame displayed based on some other criteria. So what is a series of frames can appear to be an object that is reacting to a particular force or event.

avatar image Montein · Jul 31, 2014 at 10:26 PM 0
Share

Thank you robertbu. I found what I was looking for. The answer to my problem was to use a procedural mesh. I found a great great example on the use of that kind of object in this link

Thank you so much for your patience and for your assistance.

avatar image kieyard · Jul 05, 2016 at 04:00 PM 0
Share

Hello I'm trying to deform a 2d mesh too, I'm pretty sure I'll have to use the procedural mesh method but I was just wondering is there a way to make it deform when another Sprite falls on top of it and squashes it? So it acts like a sponge and bends/squashes where the other Sprite has fell onto it?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Silly question, doing nothing? 4 Answers

Animation Cycle Dilemma 0 Answers

Anyone knows how to refresh tiles? 0 Answers

Show sprite by code from another scene 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges