Next Broadcast

First Steps into Unity with a small Project

Schmiratzma GameDev DK30 New Year 2023 3 3

Description

I want to make a minimal Top-Down Shooter. My Goals are 1st: movement with WASD 2nd: Enemies spawning randomly and running towards you, 3rd:shooting to kill the enemies and 4th: if enemies hit the player it’s game over and you get a score. Depending on how well it’s going i would love to add Features. This is the first time i am participationg in something like this and im excitet! When it comes to visuals im very insecure so i will try to keep it in the blockout stage ;) Additional feature ideas are 1st: randomized player stats with every “run”, 2nd: obstacles in the level 3rd: waves of enemies with upgrades inbetween (heavily inspired by brotato).

Recent Updates

Schmiratzma 3 years ago

I got some progress in for visual feedback. Though i haven’t spent time to make it look good, the enemies now get knocked back when hit and a Damage Number Pops up, indicating how much damage has been dealt. Next i want to learn a bit about Unity’s Particle system.

Schmiratzma 3 years ago

today i checked out, how to implement sound effects into the game. The Game Object to play a sound needs an AudioSource Component. This component can be assigned an Audioclip to play and plays the sound, when Play() is called to the AudioSource in a script. I implemented a shot sound. i don’t know anything about sounds or music in general which is why i wont do more sounds. I now know how to implement them and i can add some sounds later on. Next on my List is visual feedback. I want to spend much more time with this subject.

The last couple of days have been hard for me so didn’t make lots of progress in the game. But i did some stuff here and there. I finally finished up a minimal game loop. To start a run, you generate a random character and then jump into the first wave. After some time passed you will be able to upgrade stuff and go to the next wave. If you drop to 0 HP, you will jump back to the startscreen and can generate a new random character.

I have not really talked about this “random Character” in any of my updates so i will now. Most games, with random generation usually apply this mechanic in The world/level of the game. You start with a set character, which gets to level up and upgrade and the world stays the same only generated randomly at the start. My long term goal is to flip this around for my game. I want a random generated character and in the “upgrade” phase, you don’t choose upgrades for your character but for the world. These are my ideas:

  • You can choose from a random selection of enemies to appear in following waves.
    • many small enemies
    • some special enemies
    • one “elite” enemy with spezial rewards
  • you can purchase and build obstacles or other constructions into the world.
    • barriers
    • target dummies
    • turrets
    • oil ponds to slow or set on fire
  • As you kill enemies, they drop “scrap” the currency to purchase said obstacles/constructions

All this is just a very far away idea i want to work towards with this game to become something unique. I don’t expect myself to implement all these ideas in time but i like to imagine :)

Schmiratzma 3 years ago

The HUD was really easy to create. It will propably become hard to make it look good but i will stay true to keeping the game in a blockout stage. :)

Image of the HUD

I also want to talk a bit about my projects structure. To be able to create different enemies, and level up the player i tiped my toe into Scriptable Objects. These objects are not created in a Scene, they are only there to safe data. Previously i saved every parameter (like movementspeed, attack damage, health and so on) in their scripts. I now have Scriptable Objects, that are referenced by Objects to load the parameters they need. For example i have an “Enemy” Scriptable Object. I can now create different Instanzes of this scriptable object to change parameters like, speed, damage, health. This will give me the opportunity to create many different enemies easily :)

Schmiratzma 3 years ago

Hello, I have been quiet for a bit but i got sooo much done! Here is the List of stuff i want to do. I crossed the things i am already done with.

List of feature to add
  1. HUD
    1. Health, Timer
    2. Wave counter, Resource
  2. Statemashine
    1. Gamestart
    2. In Combat (with a Wavetimer)
    3. Upgrades (inbetween waves)
    4. Game over (after reaching 0 health)
  3. Resource (Scrap)
    1. Dropped by enemies
    2. Collected when walked over
    3. Spent for upgrades
  4. Sound
  5. Visual feedback
    1. knoback on enemies
    2. screenshake
    3. red flash when hit
  6. Animation
    1. walking, idle, shooting, getting hit
  7. levelchange
    1. obstacles
    2. ponds -> slow enemies
    3. wind -> pushes enemies and player
    4. fire -> spreads over time & damage
  8. Level
    1. Spawn enemy groups
    2. make shots despawn or bounce when out of levelbounds
List of Content to add
  1. different enemies (speed, health, damage)
    1. runner: high speed, low health, low damage
    2. tank: low speed, high health, low damage
    3. paladin: low speed, low health, high damage
  2. different weapons
    1. Rocket launcher: Projectile explodes on hit
    2. Shotgun: shoot many projectiles
    3. mashine gun: shoot fast
    4. sniper rifle: piercing projectile
Schmiratzma 3 years ago

After solving all the issues with movement, I got to start with my next Point: enemies. This meant i had to make Decisions again.

  • Should enemies be a tough challenge or more for satisfaction?
  • how many enemies should there be?
  • where should enemies spawn?
  • how do they interact with other Game Elements?(take Damage from shots, deal damage when touching the player)

This time I want to base my decisions on how easy to implement i think they are. Because of that i was very fast with a working result (at least for my pace :D).

To set up a spawning area, i created 2 Empty GameObjects for top left and bottom right coordinates and spawn an enemy every second with a random position within the spawning area. Enemies loose x health when shot and deal x damage, when hitting the player, whenever the player looses health, the player becomes invincible for 0.5 Seconds. I can change this if and when i want to but for now it works! This brings me to my next point: My minimal Goals are all finished! Whats next?

There are soooo many ideas of what i would love to add to the game - i don’t know where to start and i feel overwhelmed. To keep up the pace and not get lost in so many possibilities, i will make a List of very small things i can get done fast and work on them one by one. This List will be split in 2 different Categories: Adding to existing stuff (like different enemies) and learning new Unity stuff (like a HUD and other visual feedback). When I am done with the List i will post it here. :)

Schmiratzma 3 years ago

So i got to learn about the difference of Unity’s “Update()” and “FixedUpdate()”.

The Update Function is called once per Frame. FixedUpdate is called once per physics calculation. The physics system from Unity has a default (interchangable) fixed frequency to run every 0.02 seconds. This causes the FixedUpdate to run independent of the Framerate.

So a small Example:

If the Game runs in 25 Frames per Second (fps), Update() is called 25 times whereas FixedUpdate is called 50 Times (1s / 0.02s = 50).

Since i used movement in Update and Unity’s Collision runs in FixedUpdate they were both calculated separately which caused the wobbling of my Character running into walls. I now have converted every movement to run in FixedUpdate and everything is fine! :D

My next goal is to implement default enemies, spawning randomly in the wold and running towards the player. After that i will add the interactions between shots and enemies.

You can click the “Right Collision” and “Wrong Collision” to see a gif how it looks.


Wrong collision:

Right Collision:
Schmiratzma 3 years ago

Today i wanted to make the level boundaries, where player, enemies and other things can’t spawn or move outside of. Turns out this is the first thing I’m really struggling with. I created Box Colliders around the level but the way i set up my player movement made it so, the Colliders don’t work properly. So i changed the player movement. The Borders now work but my aiming and shooting is very broken. :( I will sleep over it and try to find a solution tomorrow.

The way i understand it: Unity has it’s own physics calculations. If you want Unity to calculate collisions for you, the Objects need Collider Components. Moving objects will also need a Rigidbody Component to handle movement. Before i knew about that, i was just changing the position of my Player Object corresponding to Input. The problem with my movement and Colliders is, that the player always runs into the wall, and the Rigidbody tries to pull it back out. This makes it look very wobbly, when i run into the wall. To solve this problem i use the Player’s Rigidbody to move. In my code it barely makes any difference but it doesn’t wobble anymore!

previous Movement: transform.position += new Vector3(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")) * speed * Time.deltaTime;

new Movement with Rigidbody: rigidbody.MovePosition(transform.position+ new Vector3(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical")) * speed * Time.deltaTime);

notice, that the only difference is at the start

Since i calculate the aiming and shooting in the old way, the wobble came up there…

Tomorrow i want to check how i can fix my aiming and shooting. I Expect it to resolve around Rigidbodies as well, which feels kind of odd. Maybe i can also find a way to make the walls work in my “old” way of movement because i understand the old stuff much better then this magical Unity Blackbox of Colliders and Rigidbodies :)

Unity has Functions which are called per frame:

FixedUpdate() and Update()

i don’t really know the difference yet so i want to put in some time to research these 2 things.

Schmiratzma 3 years ago

I now have a background and the Camera is following my player. The Gun now rotates around the Player and i can shoot! I watched tutorials from the Youtubte Channel Coding Monkey: https://www.youtube.com/watch?v=Nke5JKPiQTw https://www.youtube.com/watch?v=fuGQFdhSPg4 I’m not a great fan of following tutorials becuase i feel like i don’t fully understand everything and i might run into problems if i want to change something later on. But it provided me with a quick solution! :)

Since i am able to fulfill my goals i want to take my time to write about something i have encountered everywhere in this process: Decisions! In the Process of making a game i am facing questions constantly. If i want to advance in a quick pace these questions need answers. Let me talk a bit about one example. My goal for this project is the bare bones of a top down shooter with core mechanics, like walking shooting enemies hunting you. But i think there is not this one recipe of mechanics making a top down shooter. When it comes to the player my first question was: “Which perspective is the game in?” Is it fully top down like in “Hotline Miami” or are the characters drawn frontal like “Enter the Gungeon”? To answer this question i have to make a decision for my game impacting my work tasks. If it’s completely top down, my character has to rotate with the mouse position. If it’s frontal, the player itself shouldn’t rotate (only maybe the gun)! Making these decisions fast, helps me to progress faster because each decision requires different solutions! I want to write about a Decision i take every day. Even if i make a decision i regret afterwards, my main goal with this project is to learn unity! Tomorrow i will make a decision about the world. Whether it’s “infinite” and enemies spawn around the player of if it has boundaries.

Schmiratzma 3 years ago

The player Character (red square and a white rectangle as a gun) can now move with WASD and rotate towards the mouse position. The camera should follow the player, and i need a background with it, so the player movement is still visible.

Estimated Timeframe

Mar 4th - Apr 2nd

Week 1 Goal

player with WASD movement

Week 2 Goal

enemies Spawning and running towards the Player character.

Week 3 Goal

Shooting in the direction of the mousecursor.

Week 4 Goal

Came over condition, scoring and replay functionality.

Tags