• 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
2
Question by grybas · Apr 18, 2015 at 08:50 PM · texturespritespritescombinecombining

Combining multiple sprites

I am making a game where there are a lot of blood sprites, dead bodies. Each bullet hit instantiates new blood sprite object and eventually game starts to lag. How can i combine all these blood, dead bodies sprites into one big sprite or texture? I would like effect like in Crimsonland, where u can have infinite amount of blood sprites, dead bodies.

alt text

toforum.jpg (108.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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by LMan · Apr 18, 2015 at 09:04 PM

I would suggest an object pool pattern.

Basically, keep a large number of sprites already instantiated in the level, but deactivated. Rather than instantiate a new object (which you might be finding expensive), simply reposition and activate an object from the pool. You can then fade the opacity over time, deactivate, and put the object back in the pool after it's no longer needed.

As far as combining the sprites, you'll want to look at batching

if you use an image editing program, (ie. Gimp, Photoshop, perhaps even MS Paint.) You can put all the sprites on the same texture file. This will cause many of the draw calls to anything on that one texture file to "Batch." Which will save you processing power.

Comment
Add comment · 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
1

Answer by nasa8 · Mar 15, 2016 at 01:38 PM

This is quite challenging task I suppose. I think of two options:

1) You can combine all the spilt blood into one sprite

2) Combine blood into one texture for multitextured (may be triplanar) terrain or something

The first way is easier to implement I think. If I were in your shoes I would try to combine all small sprites into bigger one changing it's texture dynamically by SetPixels method. Read texture of a small blood sprite by GetPixels, then calculate the offset for your big sprite and put there your change using SetPixels.

You can find the description of Set/GetPixels in Unity Scripting Manual.

Comment
Add comment · 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
0

Answer by DanBarreno · May 10, 2019 at 07:13 AM

I mentioned this post here

Comment
Add comment · 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

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Difference between Sprite and Default texture types? 0 Answers

Sprite Editor Problems 2 Answers

Are shaders more efficient than manual pixel replacement? 0 Answers

Compine 4 sprites into one big image 0 Answers

2D sprite renders a small part of another one with "Sprite Mode : Multiple" 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges