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 asdasdasdxxxxxx · Aug 21, 2015 at 12:23 PM · pixel2d collision2d physics

2D pixel collision & destruction

Hi all

I'm building a 2D top-down farming game, and I'm building the system to harvest crops.

My first thought was to have the combine harvester drive over the "pixels" and harvest them, kind of like using the eraser in paint, but I can't find any solid leads on how to achieve this.

Most searches ended in people trying to make worms clones, which seems overboard for my needs, but it also revealed this this sort of pixel-lvel collision detection is a huge obstacle for Unity to overcome.

I mean, I could use separate colliders for each pixel, but that's very heavyweight for what is, at the end of the day, a simple part of the game.

I've implemented a system of larger "pixels" with their own collision detection, but it's not as pretty or as elegant as my original idea, and an entire block disappearing as soon as it's touched isn't nice.

Can anyone offer a nudge in the right direction?

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

Answer by FortisVenaliter · Aug 21, 2015 at 04:17 PM

The best way to do this would be with a texture mask. You want an invisible texture that represents your field. Black is harvested, and white is harvestable. Then, when you drive over it, you color any white pixels covered by the harvester black.

In the shader for drawing the farms, you need three textures at least: Unharvested diffuse, Harvested diffuse, and the mask. You'll then sample the mask, and use that to lerp between the two diffuse values.

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 asdasdasdxxxxxx · Aug 21, 2015 at 05:09 PM 0
Share

That sounds perfect! How would collision detection work on a setup like this? I mean, finding a pixel-perfect point on the texture to change the mask?

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

2 People are following this question.

avatar image avatar image

Related Questions

Why Does Object Keep Getting Faster? 1 Answer

How do I make my player jump? Unity 2019,How do I make my player jump? 1 Answer

OnCollisionEnter2D not triggered 3 Answers

Lag Caused by Overlapping 2D Colliders 1 Answer

Model stuck on collider 1 Answer


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