Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 Notter · Nov 05, 2015 at 02:59 PM · collider2dspriterendererui imagemasking

Not sure if I should use UI or SpriteRenderer. need to detect collisions.

I'm in a weird situation and i'm not sure what's the proper method to use.

In my 2D game, i have a spoon, and i have a Cup. The cup got a liquid sprite at the top, and i want to stir the liquid (start an animation) when the spoon touches the liquid, when i drag it there.

So far, i've made my whole game by just using UI. but at first, i tried making the cup/spoon on the world layer (Not UI), but i ran into a problem: I can't use masks! masks exist only in UI, and i need a mask for the spoon to be "half in".

So next, i gave everything an Image component and moved it to the canvas. but now i have a different problem: there's no collider triggers in UI! and now i can't know when the spoon is where the liquid is.

So, what is the correct way? which way should i use going forward? And is there no easier way to mask sprites outside UI then use a complex shader? (that i don't know how to use)

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 JoeStrout · Nov 05, 2015 at 04:24 PM

I would use sprites, and yes, you could do a mask like that with a shader, but in most cases it's easier to simply put another sprite on top.

In other words, divide your cup into a "back" sprite and a "foreground" sprite. Then simply layer the spoon between them.

You will of course still need to make sure the spoon doesn't poke out the side of the cup (though if your cup doesn't move around, the "foreground" could actually include a bit of the table/desk/whatever around it as well). But you can do this in code, just by limiting the position of the spoon.

Comment
Add comment · Show 1 · 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 Notter · Nov 05, 2015 at 04:36 PM 0
Share

Thanks for the answer.

I was also thinking about that option, but since in UI there's the mask component, i was not very confident on how to proceed.

well, time to get our graphic designer to cut up the cup sprites :)

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.

Follow this Question

Answers Answers and Comments

32 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Sprite Mask seems to override Sorting Layer preferences... 0 Answers

Warp Image/Sprite Anchors? 1 Answer

Arrays? ↓↓↓↓↓↓↓ 2 Answers

Best practice to display an icon 0 Answers

How do you make a circular player? 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