Pagina's

Saturday, 27 April 2019

Objects and children

So, yesterday I added a lot of AI behaviour for the Unfriendly Guy, the guy in the red capsule and it went quite ok. I had some code from my old iteration of the game that had a finite state machine in it and I copied it to the new one, with some additions and changes. When I tested the patrolling behaviour, this happened:


When I could not immediately spot it, I decided to call it a day and have a look later, because it was already quite late and I was tired, but I found it oddly regular what Unfriendly Guy was doing, so no worries. I can fix this easily with a fresh look.

So I turned on my computer this morning and this is what I saw:


Here is the problem. The fact that all was so regular and nice was because the script was working just fine. The NavMeshAgent (the green cylinder) was doing exactly as planned and walking from waypoint to waypoint, avoiding the walls. All I needed to do was make sure the guy was at the same position and rotation. The body was at a different place than it was supposed to be. So I put the Z and Z axis of the body to zero and moved the cylinder to the place where the body was standing, taking the body with me. Now it works.

So, note to self and my first tutorial-a-like thing: when you move objects, make sure you move the right object if they are connected and you want them to be at the same transform.

Wednesday, 24 April 2019

A friendly NPC to console me

Sorry, but I'm a bit cynical today. Today was the day my favorite team really relegated. They could get second to last, but a 0-4 loss is just enough. Having said that, I needed a friend to console me and who better to have as a friend as one you can create yourself: The Friendly Guy.


Friendly stands next to a wall, arms wide open and has a certain presence in having components in Unity. Further, I saw worse goalkeepers today, but Friendly Guy does not do anything at all. Yhe player script understands it's something to talk to, but that won't get you very far yet. Tomorrow perhaps. For now, this is my new friend supporting me in these hard times.

Other things I did today are less visible and less comforting, but useful to keep track of objects(and probably better goalkeepers too). In short, what it comes down to is that I created several short scripts to help distinguish between different types of WorldObjects. All interactable things will have a WorldObject component to make them visible in the GUI and the rest is up to those components. 

Doors have opening and closing mechanisms, weapons can be swinged, food can be eaten. That kind of stuff. I had some door swinging behaviour in the world object and I wanted to get that to a specific script so that I might not risk opening and closing apples later. Not fun, not exciting, but important to make the programming job easier in the long run. So it's good. Better than some goalkeeper, I might add.

Monday, 22 April 2019

Small GUI additions

Today, I had about 2 hours to work on my game, as we just returned from the inlaws (which are lovely people) and I tend not to take my laptop with me when going for visits to them. Thats one of the perks of Easter. The aim of Easter is obviously to work on games - or else they wouldn't have called those funny features Easter Eggs - but now I hardly had any time.

What I did do is a couple of small things. First I changed the direction markers of the minimap to make sure to the front is always upright. I used to have the markers standing upright when facing north, but that did not make sense. Now the marker will be better. I will probably make the yellow player marker a bit bigger later, but I'm not sure yet. It all depends on how it will be in proportion once I put other elements in. Whetever that is going to be, don't expect the minimap showing random elements like "red ball". I found a quote on Twitter this week. If you put vital information on the minimap, players will look at the minimap and not at the game. We should avoid that, shouldn't we?

Another thing I made was a little change in the interaction script. Things could be interacted with if they had a WorldObject component, which is probably not very flexible, so I changed that to checking for a tag. Once the tag is correct, the interaction routine will find out what kind of interactible object we're looking at and that saves getting non-existent components. Not too big of a change, but a change nonetheless. I'm probably changing that later still, when I will have classes derive from the WorldObject, but we'll see how that goes.

Lastly, I reintroduced the Healthbar. I wanted to make it flexible too, so I made a system that will be able to be introduced with enemies and other guys too. One just links a health system and it'll be able to show health and fatigue for the health system. It all happend by changing the scale of a pivot object:


The only thing I now need to do is add a health system to the player and make it calculate the values of the scale between 0 and 1. That value should be the scale of the pivot.

Having said that, that is the bit of UI I wanted to do in the short run. After linking the bars to the player, I'll enter my first NPC, a friendly guy that will give a quest involving a red ball, probably. That'll take a lot of extra steps. I'll need a guy graphic (which is going to be very poor), a quest system, a journal and a bit of interaction between the player and the NPC. Should be enough for the week.

Saturday, 20 April 2019

North, East, South, West

I already had a mini-map in my old game, but I was not happy with it, because it lacked flexibility to have other objects plug in or not. That's why i decided to rebuild it and make a camera that can only see specific kinds of things: objects with a MiniMap layer.

I put a Camera way over the player object and let it look straight down. It does not actually look for the objects on the ground, but at quad objects, flying in the air. Game development is sometimes just magic, because we're talking about three-dimensional objects that only have one side. Rotate them right and you can draw something on the top side and from the side and the bottom, you can see straight through it. Next, remove all shadow casting and receiving and remove the collider and we're good to go.


I also put NESW markers on the side of the minimap to indicate the direction the player is going. The player always goes upwards on the screen. Now that I'm writing this, I see the markers rotate wrongly. If you're going south, they will be upside down. That I'll fix later this week. 

Now It's time to go to bed. Happy Easter everyone.

Friday, 19 April 2019

This opens doors

Today I've been practising with opening and closing doors via the Animator in Unity. I got rid of all the DoorScene stuff that caused me all the grief because changing Scenes was buggy and I rebuilt a Door object consisting of a pivot and a cube, plus an empty object Orientation for later use. What I wanted to do is just like in the older version, which is opening and closing it without major bugs, so I added a couple of animations:


I find myself having a strange talent in making things that are kind of creepy in their just-not-rightness, like the old Creepy Guy that turned to watch your every move. I don't know what is creepy about the doors really, but they are, in some way.

So I needed to plug the animations in an Animator component. Then I replaced the doors by the prefab I was working on and voilĂ , doors that actually work:



 Doors are now just objects with a type Door and a name to show on the UI when looking at them. Depending on the type, the UI also shows a message to press E to pick up, open/close, interact or whatever one can do with certain types of objects. Pressing E then changes a flag in the door object and triggers a parameter that controls the animation to run. When the door swings open, the player can walk through, because the collider of the door moves aside. Just like in real life.

Another very related thing I did was with the red ball. I can now really pick it up. Earlier I announced that I could, but yesterday I saw that adding the ball to the inventory object did not really add it. I don't really know why, but I managed to fix it by letting the Inventory class derive from MonoBehaviour and then connect it to the player.

Next I'll add two basic elements to the screen, the major healthbars (health and fatigue) to the bottom left and a minimap to the top right. Not the nicest thing to do, but I'm trying to get the basic UI out of the way as soon as I can because I can then focus on the game mechanics like NPC behaviour, quests and combat.There'll be enough GUI stuff to do anyway.

Thursday, 18 April 2019

Just idly looking at the code

It seems that sometimes, one does not produce any new lines of code in a day and still feels productive. Maybe it's me, but usually, those are key days for me, because those are the days ideas just happen.

Today, I was thinking about objects in my game and how to interact with them. Had a little conversation online about destroying and deactivating them and in the future, arrows will be pooled and deactivated,  while money'll be destroyed.  Furthermore, I will have the inventory class derive from monobehaviour, so I can add it to the player directly,  because why should I instantiate it manually?

Those doors have been a torn in my side too long, so they'll be gone and replaced by something else that I will build myself and not take from a tutorial.

Funny thing about failure and idleness is that it gets under my skin and that brings the will to conjure up solutions.

Am I already some modern day Confucius?

Wednesday, 17 April 2019

A new Unity version

Alright. So nobody into gamedev videos could have missed this. Unity is releasing a new version: 2019.1. A lot of people are excited by the new rendering update with the video that was presented at the conference a couple of weeks ago. Myself, not having scratched the surface of the current 2018.3 versions, I just see extra options that I did not know about yet.
What caught my eye was a demo on terrain creation. I have worked with it in the past, but am looking forward to the new options in making bridges, erosion and the like. I saw the video in the bus today and it sparked my fantasy vibe in map making, a hobby from high school time. Not that I made a map or something,  but I surely will soon.
I did not do much programming today. Bit failing around on Blender,  trying make a sword. For the rest, tv time is important to.
Anyway,  here's the video I'm talking about ..