Day 2 at the Jam


Day 2: The Waypoints Directions and AI

After coming Back from Work I started working  on the Enemies. I thought about my 2D Games, where I already  used Waypointmovement. So I used the knowledge from there to creat my new Towerdefense Game.

Structure: Enemy will walk towards a Waypoint. When the Player is in Range, the player will be attackt. If the Base is in Range, the Base will be attackt. Sweet. Idea set , started: I use a Array of Transforms to place the Waypoints in the scene. Then I add in an integer to set the Waypoint ID. Next I tell the Enemy Object to move to the Waypoint[ID].position, until the range is below 0.02f and then set the ID one higher until the last Waypoint is reached. The waypoints will be set in a line towards the Base.

Next to the movement -> Straigt movement will not work. So I had to setup Unitys AI (NavMeshAgent) which is already implemented at this point.

Setting this up is fairly easy. Simply reference it in Code and then use the NavAgent.Stopped = true or False to aktivate the movement. And to set the movement you only neet to Set a Destination with NavAgent.Destination = …

Workes very well!

After That I started working on the Shooting. I tried around some Bullets and Physics and Movement towards a Direction…. There happened a lot of funy things. I had to watch a Brakeys tutorial where I learned that you have to set a Direction by

 “target.transform.position – My.transform.position” 

That means, you have to set the TARGET first, and then subtract your position.

I noticed that brakey was making a TowerDefense Tutorial where he explained that, to I could use the Tutorial to create the Towers too – which used the Same Direction Code.

Then the “Rotation” came into play. Which was a horrific task for me because I have no clue from Quaternions.

The Code I got from the Tutorial is this:

  Vector3 dir = target.position - transform.position;
  Quaternion lookRotation = Quaternion.LookRotation(dir);
  Vector3 rotation = Quaternion.Lerp(Turret.transform.rotation, lookRotation,   
  RotationSpeed * Time.deltaTime).eulerAngles; 

  Turret.transform.rotation = Quaternion.Euler(rotation.x,rotation.y,0f);

I didn t know, if you want to set a “look” direction, that you have to get the Direction, then make it a Quaternion, next add the Quaternion to a Vector3 and finaly set the Vector3 as an Quaternion.Euler….  I hope I ever finde a more easy way than this.

https://www.youtube.com/watch?v=QKhn2kl9_8I

After I got this all down, I could finaly make my Enemies shoot at Targets, and the Turrets shoot at enemies.

Next I started decorating the World with some Rocks, and added Portal for the enemies and Placed stuff.

Then I created the Enemie Spawner which was done very quick I just looked at the brakes tutorial if I got everything correct and it worked right out of the Box.

Then I noticed that I was making a very clean looking 3D game, and  (thanks to) styxcolors told me that the GameJam will have to be Pixel or Voxel in some Kind. -> so I was a little devastated left the GameJam and went for a afternoon sleep.

When I woke Up I had an Idea: How about “PIXELATED SHADERS” … or textures… or stuff. I searched for tutorials and found very strange ideas.  I downloaded a Shader… which didn t work. Tried around with Textures and then I got a Tutorial which helped a lot!

RENDER TEXTURES!

I used them Once for a Minimap -> you simply create a texture which you could set to a material or a RawImage un UI, and then you tell a Camera in the scene to render the recordings to the texture.  So far, so Simple. I set the Texture made the Settings to fit what I need and TADAAA it worked … next I had to decrease the resolution of the Rendertexture so it will look like pixels. That works also very well!

I noticed that a a lot of people have issues with the UI when they do so- I could work aorund all thos issues by putting the render texture on a separate canvas and set the Sorting order to -1 so its renderd below other Canvas and UI Elements.

Next I wrote a Resourcemanager, made it overcomplicated and gave my self a hard time later in “getting” the right value. But it works now. I overscaled the Class for a big Game and more than 3 resources… so I could scale this Game up to infinite number of resources but only need 3  -> basicly its to big but does what it should do.

After Finishing the Resourcesystem I implemented a Laser with a Linerender what I also never did befor. The Tutorial I used was again very helpful and explained everything very easy so I could make my Player use a Laser to Mine Resources and shoot at enemies at the same line of code.

https://www.youtube.com/watch?v=YjpKxjzwado

 I made a seperate Tutorial on the Render Texture Topic.

Next I created Ressource Nodes to gether and spread them over the howl map.

After that I let my Girlfriend play the Game for the first time, she was having fun but noticed that she felt kinda lost, and couldn t find her way to the enmies, or the Base. So I Made a Minimap, added some Minimap Icons above everyone, set up a Layer for Minimap Icons, and created a new Camera with Render Texture overhead so we see a little better where we are.

Alot done for the second day but its 2AM ... so thanks for reading.

Get [GameJam]Encounter on AZ-2

Leave a comment

Log in with itch.io to leave a comment.