Autor: badwaz

  • Coding a Weather System [PART 1]

    Coding a Weather System [PART 1]

    Hello everybody! Lately it came to my mind to create a small weather system for my game in Unity Engine, as I want it to be dynamic for each day and depending on the season. On a playable level it will affect the gameplay, but for that there is still a lot of time and planning to do.

    But, creating the system that I want to change the weather I could do it now without problem, since it is practically all logic and not touching much in the editor part, or at least, in this first part of the tutorial.

    As always, this code can be improved, for sure, but at the moment this is my way of doing it and can be updated in the future. Here we go.

    (más…)
  • Creating and saving a mesh for a stylized waterfall generator

    Creating and saving a mesh for a stylized waterfall generator

    Okay, it seems that the title is tremendously specific, but this can be used for things other than waterfalls, but it is true that I made it thinking about it. In this tutorial I will create a CustomEditor to create and delete GameObjects at edit time, save the positions during several seconds of GameObjects to create a mesh joining the points and create and save meshes in the Assets folder of Unity. So, we will learn something.

    A small introduction

    For my personal project I’m doing, I have several areas with water planned where there will be small waterfalls around the map, and I was thinking about how I would model some of those waterfalls, since I would have to do it by hand in Blender, export it to Unity and see if it fits with what I want. In principle it shouldn’t be a problem, but I wanted to complicate my life and decided that the shape of the waterfall I would do it in Unity directly.

    (más…)
  • How to create a custom Property Attribute

    This is one of the things you think you won’t do because you’ll never need it, but creating a small tool to generate meshes to make waterfalls, made me need to display only the X value of a Vector3 in the Inspector, and the only way to do it was to create a custom Property Attribute.

    The complexity of creating them depends on what you want to display in the inspector and what function you want it to do.

    First of all, you must have in Assets a folder called Editor, and this is very important, because if you do not put the code in this folder, it will not work.

    (más…)
  • UI changes depending on the controller you are using, with events

    UI changes depending on the controller you are using, with events

    I am currently doing a personal project, in which I wanted the UI elements in the scene to change depending on the type of controller being used. In my case, that it detects when it is an XBOX controller, PlayStation 5 and finally, keyboard and mouse.

    First of all, I warn that this is my implementation and does not mean that it is the correct one or that it cannot be done otherwise. I accept suggestions and improvements, we are all here to learn.

    The new Input System and version 2022.3 LTS will be used, and I have created the following main classes:

    • GameManager: Enums are created here for the device type and the action being performed, to display the corresponding icon. In my example case, I use ACTIONS to know if it is an element to pick up, actuate, or talk, for example.
    • InputManager: Variables and functions for collecting data from controllers.
    • GameEvents: I use this class to create all the events that I am going to call, to have them all sorted in the same place.
    (más…)