Sign In

GameJam - Let's make a game with Unity and AI - Day 3

0
GameJam - Let's make a game with Unity and AI - Day 3

Objective

The idea is partecipate to a Gamejam and make a game using Stable Diffusion graphics.

Day 1 : https://civitai.com/articles/4104/gamejam-lets-make-a-game-with-unity-and-ai-day-1

Day 2 : https://civitai.com/articles/4106/gamejam-lets-make-a-game-with-unity-and-ai-day-2

Start of day 3

I started to make the Player movements with unity animation tool.

You can define different movements and then you move the bones accordingly.

There is an animator windows where you can set the different movements together with variables.

The default animation will be idle , if I walk I will animate to the correct animation and when finish to walk will go back to idle.

I assign an script to the player, I put the speed variable.

Also in Unity I assigned a "Rigidbody 2D" which will help to interact with the other objects and give physics to the player. I set the gravity to 0.. If not the default will make go down the player.

For collisions I like to user a "Capsule collider 2D", it is good because if doesn't have corners that sometimes give some issues.

Testing the animation with a test background.

Game GUI

I created an ugly GUI in Krita.

Using ControlNet with lineart

Prompt: wood Japanese, lot flower, frame

Selection One and setting high res

I am not very convinced of this one..

So I removed the borders.

Menu Font

I don't like the default font.

https://www.dafont.com/it/theme.php?cat=201&l[]=10&l[]=1

I search for 100% gratis font and I like "Karate" I download it and read the comments

Karate Font
Karate was created back in February of 1993. I worked at a newspaper and we needed a font for an advertisement for a karate teaching class. It's not what you would call great, but it has its uses.
Enjoy this freeware font!
If you like this font, send me a postcard telling me.
Gary D. Jessey
RR 1, Box 107
Jenkins, Kentucky  41537

So I will use it.

I imported to the project and created a TextMeshPro to work with the font.

Now look much better

I have also update the Intro /Main Menu / Map / Game popups

Lives

For the Life icon I user controlnet with an image from intenet and use the prompt:

red Heart in a gray background, full image 2d <lora:more_details:1>( Japanese , lot style:1.3)

Defining the enemies

Because I am al little short of time (it takes a lot to make the game and write this post).. I will make easy enemies.. static images that will move with rigs.

I decided to change checkpoint.. because I like the results:

meinamix_meinaV10.safetensors [d967bcae4a]

prompt: full body, ugly Japanese monster, (gray background:1.2)

There are perfect, they don't have background and no part of body is missing.

I removed the background with windwos paint and imported in unity (copy and paste the file in a folder)

Now I will add some behaviour

Enemy AI

I have many scripts to add to the enemies.. like follow the player. go around and attack, etc.

Let's create a script with ChatGPT (which is great, because it is complete and you have only to copy and paste 90% or the times).

my prompt is:

make a c# unity script for an enemy , he has to follow the player with random speed between 2 values

ChatGPT Answer:

Here's a simple C# script for Unity that you can attach to an enemy GameObject to make it follow the player with a random speed between two specified values:

using UnityEngine;

public class EnemyFollow : MonoBehaviour
{
    public Transform player; // Reference to the player's transform
    public float minSpeed = 2f; // Minimum speed of the enemy
    public float maxSpeed = 5f; // Maximum speed of the enemy

    private float speed; // Current speed of the enemy

    void Start()
    {
        // Initialize the speed with a random value between minSpeed and maxSpeed
        speed = Random.Range(minSpeed, maxSpeed);
    }

    void Update()
    {
        // Check if the player's transform is assigned
        if (player != null)
        {
            // Calculate the direction towards the player
            Vector3 direction = player.position - transform.position;
            direction.Normalize();

            // Move the enemy towards the player at the calculated speed
            transform.position += direction * speed * Time.deltaTime;
        }
        else
        {
            Debug.LogWarning("Player transform is not assigned to the EnemyFollow script!");
        }
    }
}

To use this script:

  1. Create a new C# script file in your Unity project.

  2. Copy and paste the code above into the new script file.

  3. Attach the script to your enemy GameObject in the Unity Editor.

  4. Assign the player GameObject's transform to the "Player" field in the EnemyFollow component.

  5. Set the minimum and maximum speed values as desired in the Unity Editor.

This script calculates the direction from the enemy to the player and moves the enemy towards the player with a random speed between the specified minimum and maximum values. The enemy constantly updates its position to follow the player.

Adding the script to the enemies

I have selected the enemies and added an empty script, then I copied and paste the chatpgt code.

I assigned to the script my player (I can also to it with code, but in this case it is ok).

I added rigidbody and Capsule collision 2d to all the enemies

what a mess... I forgot to set the constraint in the rigidbody to avoid rotating...

But you can notice that I was able to create 12 enemies in few minutes. Without AI to make 1 enemy took me ages.

Ok, now it is better.. the game it is still missing.. i added more enemies.

For the enemis I added digging without making pieces

Generating the background of the game

I will generate the backgrounds of the different part of the level with Stable Diffusion to speed up the process.

prompt:

dark sky

ADDROW

green grass pink blossoms, casting a gentle glow on the moss-covered path japanese

Used the reginal prompter with 2 rows:

The idea is go create 9 (rooms) for each level with enemies, keys and doors.

In one scene I will add the images

Some concept for the game levels.. with background and images generated

I have to add for each scene

  • Collision to remain inside the scene.

  • Point to move to another scene

  • Camera movements (should follow the player to another scene)

Also make the other levels

TODO.

  • Generating the Doors

  • Generating the Keys

  • Generating the Ammo

  • Putting all together

  • Design the levels

  • Making the levels

  • Adding music

  • Adding some effects

  • Adding Sounds

  • Testing the game

Publishing

  • Compiling in for Web

  • Making the Itch.io page

  • Generating the itch.io logo (630x500)

  • Generating the itch TopLogo (980x250)

  • Adding the text to the page

  • Adding images to the page.

  • Writing the Golive Article

  • Releasing the game.

0

Comments