Sign In

AI Tools - How to create animated sprites to use with unity or other game engine.

AI Tools - How to create animated sprites to use with unity or other game engine.

Index :

1) Generating the sprites with Stable Diffusion and Animatediff

I have selecte as checkpoint the great RealCartoon3D.

Then I puy my prompt:

(lateral view:1.5)( walking animation:1.4) (horror animal :1.7) full body (steampunk:1.4) chibi , gray background

Negative:

blurry, blurry_image, Lowres, Low_resolution, Low_picture_quality, Low_picture_anime, extra_anatomy, extra_body, extra_navel, extra_face, extra_eyes, extra_chest, extra_nipples, extra_hips, extra_arms, extra_hands, extra_fingers, extra_legs, extra_feet, extra_toe, missing_anatomy, missing_body, missing_navel, missing_face, missing_eyes, missing_chest, missing_nipples, missing_hips, missing_arms, missing_hands, missing_fingers, missing_legs, missing_feet, missing_toe, sketch, sketching, (worst quality: 2), (low quality:2), ((monochrome)), ((grayscale)), inpainting, HDR, bad_prompt_version2, jpeg artifacts, signature, watermark, text, error, missing fingers

Size : 512x512 , Sampling method: Euler a .

Then enable AnimateDiff and set 16 frames (will create 16 images) and set only the option PNG.

If you don't set the Seed and work with generate forever you can create a lot of different animation sprites for your game.. Try also with 32 and 64 frames.. sometimes are good.

Because some games don't need 512x512 sprite you can use also 256x256.. it will speed up the generation process. The quality of faces is not the best, but if you resize the sprite to 64x64 or 128x128 ore less (32x32) it will be fine.

You will see the grid directly on Stable Diffusion. The only issue is that the background is not trasparent.

2) User the new Windows 11 paint to remove the background of each file.

The Microsoft tool has improved a lot lately (you can also generate images from it with cocreator, but it is quite limited compared with Stable Diffusion).

Open the output, you will see all your images, I normally put paint in a windows near and I drag my images , press the remove background and save it. Then drag another image.. it is a fast process (if you don't have 1300 images.. like it was in my last game).

Here is the procedure for one image.

Drag your image on Paint.

Press the "remove background button" on Paint

This remove automatically the background.

Press Save.... then you can drag another image again.

A little video where I show how I remove the background quickly:

3) Put together the images in a single spritesheet.

You can do it manually with Krita, Gimp, photoshop or other tools.

I have developed my own tool to speedup the process. I will release for free when I will make it nicer.

4) On Unity you can then take the file and make split the image grid

5) Drag the image to generate the sprite

Select the Images and drag them to the scene and it will create an object with attached and animator and set all the images as animation.

Your sprite is ready to be used on the game.

Of course at this point you can change the animation, set the Rigidbody2D to the sprite, add the collision and add some enemy behavior.

6) Adding enemy behavior (using ChatGPT)

Go to ChatGPT and write : write a C# code for unity to add to my enemy that has to stay still and move against the player when the player it is in a specific range.

Add the file to your object and it will work normally (sometimes you have to check the code for little issues).

I hope you enjoy.. and good developing with AI.

28

Comments