Tag: unity

  • “Creator Kit: Beginner Code”: Day 4

    Not a whole lot to report today — mostly spent today going through documentation, getting set up again, and trying to pseudocode my way through the effect I wanted to write out. Turns out the windup tutorial actually happens in three stages: one stage for consumables, one for equippable items, and one for equippable tools.

    In the end the thing that turned out to help me most was a combination of pseudocode and working backwards: writing out the objectives I had for the program, then taking tiny steps like “Okay, this needs to return a boolean; it’s consumable, so it returns false” and “Once all of the parameters are set up (even though they aren’t yet), I’ll pass them in here, which will perform the main point of this code)”.

    Working backwards was also an interesting way to diagnose problems, because I’ll find out later whether I’ve made a huge mistake about conceptualizing things, but in the meantime I can isolate all of the syntax issues that are happening while I try and set up my parameters, as a result of not knowing C# very well.

  • Thinking Through Progress

    This’ll just be a bit of a ramble to sort of work through my plans. Topics: the Creator Kit: Beginner Code Kit, the VR Beginner kit, designing & planning my own Unity projects.

    Beginner Code Kit

    I’ve left the Beginner Code kit so long that I can’t really remember what I was in the middle of (or where I left my files) when I was last working on them. Teach me to write up my escapades better.

    My last Beginner Code post was about finishing up the core units, not about the day I spent wrestling with writing original code from scratch. The primary reason is because I spent that day reading documentation trying to figure out what I needed to access, so I didn’t feel that I had anything to write up, but I was wrong. Oh, I was wrong.

    Probably the next step would be to go back and restart the write-from-scratch unit, working through the documentation again. It’ll be a pain to start over, but it’s the cleanest way I have of making sure it happens.

    The goal of this write-from-scratch in Beginner Code is not necessarily to mod the game, by the way. It’s to just… have something I came up with and wrote myself work. That’ll be a big win for me.

    VR Beginner Kit

    After the Beginner Code kit I have two VR tutorials on deck: one about an escape room and one that’s just a beginner’s guide. They look about comparable, which means I think I’ll go with the escape room, since it involves puzzles (hopefully).

    It’s not supposed to involve much programming, if any, which means that I’ll mostly be getting oriented in VR and thinking about how to design for it instead of doing the coding principles. Maybe I should look up a more advanced coding tutorial as well…

    Planning Projects

    The line to thread on projects is something that’s a) interesting, b) achievable, and c) relevant. A project I don’t care about is a project that will suffer; a project that I can’t accomplish (even if I have to stretch and grow to do it) is pointless; a project that isn’t useful is doomed.

    As far as Unity goes, we don’t have a lot of call right now that I can see for a project, though thinking about potential AR applications around campus might have legs. In the meantime, it’s possible I’ll try and keep my hand in by programming smaller projects outside of Unity, to keep in the mindset and the habit.

    I do have potential game ideas that would be a good way to practice full-scale development in Unity… hm.

  • “Creator Kit: Beginner Code”: Day 3

    Really, for real, almost nothing to report from today. I fixed the problem in my code, tested it (it worked, because I’m amazing), and finished the last official remaining unit in the project. The unit was to make your own script from scratch, but it was still pretty simple — writing one function which contained one line of code, and then applying it in the Unity editor.

    The main question, as always, is what’s happening next. I think I’m going to work through the last couple units of the game — there are a couple where the time-to-complete is listed as zero, presumably because they’re both optional and pretty free-form. There’s one to customize your game some more, and then a couple which look like they’re about sharing and submitting your mods, which should be quite quick.

    They have two recommended tutorials after this, one for 3D work and one for 2D work, both of which will presumably involve more coding in C#. I’m deciding whether to do them or take a whack at the beginning VR tutorial I found, because one thing this tutorial showed me is that when they say beginner, they really mean it. You didn’t need to have prior coding knowledge or experience to make this tutorial work. Which has left me a little less scared of the VR tutorials, at least the ones that’ll be holding my hand.

    I can’t remember whether I ever linked the Beginner Code tutorial, but here it is. And here’s the Unity documentation/Scripting API.

  • “Creator Kit: Beginner Code”: Day 2

    Today I went through another big chunk of the Creator Kit: Beginner Code tutorial. Yesterday was an introduction to (a review of) variables and functions, plus some syntax for C#. Today was all about classes, and I was both bored and boggled by turns.

    Bored

    It is TBQH not the tutorial’s fault that I already know a lot of the concepts they’re introducing, and that I’m mostly in it for the syntax, but still. I ended up critiquing the lesson structure in my notes halfway through, which isn’t the worst use of my time (learning how to teach is definitely not nothing), but still wasn’t… great.

    The lesson that got me was the unit about writing your own spawner class, which per my notes was structured something like this:

    1. Here’s how to write the syntax for declaring a class (always a good place to start)
    2. Declare your global variables (a good next step, though they didn’t actually call them global variables or explain what the difference would be, which seems important)
    3. Write the most important function, the one you absolutely need your class to be able to perform (a constructor, you say? no, no. just the function which is the primary point of the class. which… i get, but seems backwards)
      1. In writing the most important function, use a class and function which we have written for you elsewhere. This function should be relatively simple to write on your own, even if it would provide redundancy (I assume the function is also needed other places, which means they can’t wait for you to write it in the tutorial. But you won’t write it. We won’t tell you how it works.
      2. Here’s a hint: it’s almost definitely just a modulo operator. That’s it.
    4. Now you get to write the constructor function.
    5. But because we didn’t tell you about what public variables are, your code doesn’t work, and you now have five errors.
    6. That’s it, that’s the end of the unit. See you next time.

    I bet it shows how impressed I was.

    But it was actually good practice for writing code, and I found myself remembering syntax pretty intuitively, which was helpful.

    Boggled

    In order to treat myself and prove what a smart and special programmer I am, I decided to add in a for-loop, using a public int which one could set in Unity. The size of the int would determine how many health potions/how much money spawned at the start of the game.

    Ladies, gentleman, and those of us who know better: I broke everything.

    That’s perhaps a little overdramatic, but essentially, I crashed the Unity editor like six times. You could not change the variable and then run the game without immediately causing the Unity editor to freeze, which in turn forced me to kill the program from the Task Manager.

    If you didn’t change the variable (which by default was 0), everything was fine, by which I mean the game would run without the Unity editor crashing. Everything was not fine, in that zero potions would spawn, with no way to change that.

    Eventually I decided to put my for-loop inside a conditional clause: if the number of potions is less than or equal to zero, don’t bother. If it’s not, try the for-loop.

    This worked, in that the game no longer crashed if you changed the variable. It still left me with absolutely no potions, because the game just did not care what you changed the variable to.

    I gotta figure out how to write to the console in order to speed up my debugging. In the meantime, have a screenshot of my terrible for-loop (with the section it was supposed to replace commented out). That’s all, folks!

    A screenshot of code, consisting of the declaration of two global variables, a function which contains a variable meant to calculate angles and an if-statement containing a for-loop containing a function that is meant to spawn loot. Commented out is the same function outside of the if-statement, but repeated four times.
    Please witness that most important precursor to success: failure.

    UPDATE: I FOUND IT. RIGHT AWAY. ABSOLUTELY CLASSIC.

    (Hint: I asked i to be equal to zero, and also greater than whatever number of objects I wanted to spawn. Oops.)

  • “Creator Kit: Beginner Code”: Day 1

    So, following up from yesterday – today was about the Beginner Code tutorial on Unity. It was, as the name says, very beginner — it did a lot of introducing the concepts of variables and functions, which meant that I skimmed those sections.

    The tutorial started out pretty simple, with a general rundown of how computers, compilers and code all work together, as well as exploring the game to see how different parts of the world work. Then it went into examining scripts, and how to read through C# when written out.

    One thing I really appreciated was that the tutorial made a point of introducing a term that would make no sense without explanation, then immediately linking the documentation and walking you through how to use it. Beginning programmers, like the sort this tutorial is aimed at, may not know what documentation is, or where to find it, or even how to use it; this setup specifically showed how to find it, and then how to interpret what the answers were. This was also nice because Unity uses some specialized terms that are not necessarily present in C# broadly, so when I went to look them up in C#’s documentation, I had a lot of trouble.

    The tutorial walked you first through variables and then through functions by having you edit a script which spawns health potions at the start of the game. The variable you change affects the distance from a central point the potions spawn; the function you change refactors the code to prevent the same function being rewritten four times.

    It has been a while since I wrote code, because I made a pretty silly mistake: I didn’t type my variables when I instantiated them in my function, which led to the same error eight times over, and couldn’t figure out what I’d done wrong. Hopefully I’ll take that lesson forward. It’s been a while since I’ve worked in a strictly typed language.

    I actually worked a little bit ahead, since skimming through the explanations of variables and functions left me with extra time, and managed to get through tomorrow’s agenda and even a little bit of Thursday’s. I’ll be moving things up to compensate.

  • Code, Cactuses, and Kanban

    Not a whole lot to report today, just some floundering as I try and figure out my next steps. There’s two fronts I’ve been talking about, Agile and Unity, so I’ll cover them both.

    Agile

    Simply put: I don’t have a whole lot I can adapt for Agile in my current work. The projects I’m working on sort of suit it — Agile is about incremental deliverables which add functionality, which is a lot of what I’m currently doing in my documentation and policy work.

    But most of Agile’s (well, Scrum’s) tactics really boil down to ways to keep a team motivated, focused and cross-functional. Daily stand-ups? Planning poker games? Those are ways not just of managing information, but engagement.

    I did pick up the Kanban swim lane diagram practice, though. I have a Trello board. It’s very pretty (and it’s easy to keep notes on each card).

    Unity

    Unity today has been a lot about figuring out where I am. The most recent thing on my project chart has been working through a lot of the beginner projects — except I’ve already done most of the Kart build, and I’ve at least touched on the platformer and FPS microgames (this was back in August or early September, before I started writing things down). I didn’t want to work through a list of things I’d already done, or things which were almost the same as what I’d already done (modding out the platformer was mostly just about aesthetics, which we did a bit in the Kart game; modding the FPS game looks almost exactly the same, except that you have to purchase all the modding resources). 0/10, highly demotivating.

    After I’d finished the beginner projects (you know, the thing I didn’t do because I’d already done it), the plan was to plan an original project of my own, then create it. I… don’t think I’m ready for that yet, in part because I don’t know where I’d get assets that have behaviors and functions attached. Maybe I’d have to write my own.

    So instead, I started poking through the other tutorials Unity offers in the ‘Learn’ tab of Unity Hub. I came across one that looked particularly interesting, called “Creator Kit: Beginner Code“. It said it recommended working through one of the other Creator Kits first, so I noodled around with one called “Creator Kit: Puzzle” (I love puzzle games). But in the end, it looked pretty similar to the microgames, so I let that one go.

    This means it’s (sort of) settled: Beginner Code will be my next project. I’ll start working on learning C#, and hey, maybe I’ll even manage to go back to Codecademy for a little extra practice. I haven’t had the chance to dig into the actual tutorial yet beyond getting it just set up and imported, so there’s nothing to report on that front, but from what I’ve seen so far, it has cactuses in it. So, a win on all fronts.

  • ‘2D Game Kit’: Day 2 (& Other Projects in the Pipeline)

    Went through the back half of the 2D Game Kit (teleporting to another scene, and the video walkthrough). The video walkthrough was interesting — about half of it was information that had been covered partially or completely in the written tutorial, another 25% was inferrable, and the rest was basically new. For example respectively: monsters and how to fight/mod them; the fact that you can set up damageable obstacles and break down objects in your path (the written tutorial only covered damaging monsters, but it works the same way); and how to add items to your inventory and trigger dialogue popups. Still, I don’t think the redundancies were a bad thing, since working through a tutorial by yourself and having a game designer talk through her thought process both lay out two different and useful perspectives. Also, one noted difference between the 2D Game Kit and the Kart modding tutorial – the 2D Game Kit came with a lot of art assets, which I couldn’t change the color or look of easily. In the Kart mods, it was pretty simple to adjust the albedo on any given asset, which weren’t usually art/images.

    Other plans today: get a jump on “Getting Started with Unity”, and maybe look into some project management frameworks I’m not familiar with (specifically, Agile). The Getting Started tutorial looks like it’ll have some redundancies for me — I already worked through go-kart modding, I’ve tooled around a bit with the FPS intro project, and I have at least passing familiarity with the Unity editor by now — but there may be some new tidbits.

    Re: Agile, I’m passing familiar with the concept, but I don’t have a lot of experience with how to apply it properly. What I’m hoping is for better information on how to set up those sorts of recurring, multi-step processes (or whether Gantt charts can be extended easily and intuitively into an Agile framework, because I like Gantt charts a lot).

    This’ll teach me to look ahead — I started poking through “Getting Started with Unity” and it turned out that a lot of it was geared specifically towards the sorts of streams I already worked through with ‘Your First Game Jam’! I’m now wondering whether to work through the FPS and platformer exercises, though I’m planning to skip the kart modding section… but maybe it would be more worth it to move on to a different tutorial?

    As for Agile, I ended up going through a LinkedIn Learning tutorial on “Agile Foundations” that has been pretty disappointing so far. There’s some good information about Agile’s values and mindset, but most of it is evangelizing. I’m hoping there will be more actionable information later on, in the section devoted to Scrum, Kanban, and something called Extreme Programming (!).

    Overall, a pretty scattered day, but I feel like I at least got information I can use in a couple different areas.

  • ‘2D Game Kit’: Day 1

    Today we’re getting started on the 2D Game Kit! The last tutorial was entirely a 3D environment, which was good on the theme of working towards VR, but I’m hoping the 2D Game Kit will give a bit more variety of skills and practice with what I already have.

    Getting quite honestly kind of annoyed with the number of updates Unity puts out. Can’t tell if they’re treating every version as distinct or if each thing is just a few small patches, but it feels like every version is a new and distinct one and they push a new one every two or three weeks. Might just be me though.

    The 2D game tutorial is so far a lot more approachable than any of the 3D tutorials (though that may be the fact that I now have some idea what I’m doing). We’ve covered adding prefab assets, as before — this time, tile painting in order to generate platforms, and the ability to add a prefabricated moving platform. The tutorial shows how to get it to move in a square loop, but I decided to set mine up to move in a triangle.

    The tutorial was actually so straightforward that after my initial notes above, I didn’t end up noting down anything in particular I was having trouble with. Very clear drag-and-drop across the board. It was actually so clear that I’m curious what the walkthrough video will consist of, since the whole thing is another 45 minutes long.

    The 2D Game Kit tutorial I worked through today can be found here: https://learn.unity.com/project/2d-game-kit. I got through parts 1 and 2, though I didn’t finish the last bit (teleporting the player to a new level).

    One thing I ran into which I’ll need to look up a bit more: occasionally I would put a piece of environmental background art (extra backdrop, usually, as I ran out of room on the level) and then be unable to put any ground tiles on top of it. Tomorrow: putting the final touches on teleportation, and seeing what may come from the walkthrough video! (And possibly more…?)

  • ‘My First Game Jam’: Day 3

    Today’s technically day 4, but I got very little done on Friday, and day 3 started by finishing up what I started then. Which was… drumroll… machine learning! Not programming machine learning, but learning how to add a second AI-controlled kart to my karting game, then set up checkpoints for the AI to follow so it could see how to go around the track. I need to neaten up my checkpoints a little – at present my AI gets frightened of a big jump halfway through and turns around to go back to the starting line, where it gets confused and has to stop.

    Setting up the AI kart controls involved making a prefab object for the AI to use as a checkpoint, distributing it around the track so the AI could always locate the next one, setting all the checkpoints as a trigger event, and placing them on the ‘Training Checkpoint’ layer. And also making them invisible, so that I could see the rest of the track (turn off the Mesh Render for this bit).

    Next we moved on to a bit more decoration, aka using billboards – you can set images as an object’s texture using the albedo! Still haven’t answered my question from day 2 vis-a-vis what got my colors stuck, but cool nonetheless.

    Learned how to add new cameras, position them and make them follow the player – you can add them through the main scene editor, position them by aligning with the view (or moving them as you’d move anything else) and attach them to the player by putting them somewhere inside the player’s hierarchy and positioning them accordingly.

    I got to learn how to make new scripts! You can write a new script by creating it as a component, then opening it with your text editor, and proceeding from there. I’m having some issues with mine, however. I copied the code directly from what they were doing, but it looks as though variables that are instantiated but not initialized are meant to be able to be set in Unity. In the tutorial, they have blanks which can be filled by other game objects, but my Unity workspace isn’t displaying them.

    Update: found the issue. I had a double in my code that was meant to be a float. (Can you tell I’m writing these notes as I work through the exercises?) Running into some new issues bugtesting, though – namely, I’m very bad at driving the kart.

    Animation notes: have to create an animation as an asset (apply through Window > Animation > Animation when you have something selected, then hit ‘create’). Created through keyframes – position it where you want it at a keyframe!

    Also some interesting experiences with bugfixing and post processing. The first rule for bugfixing: don’t write code you don’t understand. I ran into an issue that wasn’t even a bug (on Unity’s part). I had an error that didn’t affect compiling, only a piece I had deactivated, so I was fine running the game with it, except I had Error Pause turned on, which meant any error would prevent me from playing the game. One fun bonus of following a tutorial livestream is watching people with more knowledge than me hit the same bugs I’m running into.

    I actually got through the entire rest of the tutorial today, which was honestly pretty incredible. The streamers’ process started to unravel a bit towards the end, when they ran into bugs which they didn’t have time to address and started taking requests from their chat which was overambitious for their time limits, but honestly, that was pretty bolstering. It’s a good reminder not to be intimidated by people who do this professionally — everyone starts somewhere, as they reminded everyone at the end of the stream!

    I’m not going to move onto making my own projects yet; I want to practice with some more tutorials and pick up more skills (especially problemsolving skills) first. I may also look for some C# tutorials so I can understand what it is I’m trying to write when I code.

    As I mentioned before, this stream was located here: https://www.youtube.com/watch?v=Dweo04X7mJU

    It was part of this tutorial: https://learn.unity.com/tutorial/join-your-first-game-jam-1

    Give it a try — it’s much less intimidating than you’d think! And if you’d like to play my game, it’s available here: https://connect.unity.com/p/the-zoomies/ (You have to knock down the donuts; for some reason my change to ‘pins’ in the instructions didn’t take.)

  • ‘My First Game Jam’: Day 2

    Still working through the livestream tutorial, as yesterday. I didn’t get a whole lot done today — my Unity files had gotten out of date, so I had to update a lot of packages before I could get started with the build. Only got through about half of what I had planned, but it was an important chunk nonetheless: how to add assets, add collision physics, and set up events to trigger!

    Clicking and dragging an asset onto the scene adds it to the dropdown menu on the side (technically, we also did this yesterday, but I count it towards today because we did more editing of the asset today). From there you can click into the asset’s menu and add components. Adding a BoxCollider makes the object solid, so you can’t move through it the way you might be able to for other objects. If the object has a script for it, you can also add particular events to trigger when you interact with it, like making a certain sound effect play. I did run into a weird issue where I couldn’t change the color of certain prefab assets, which is something I did a fair bit of yesterday. Haven’t resolved it yet.

    Questions for the future:

    • How do you add events to objects that don’t have scripts for it?
    • What about certain objects (or certain Unity configurations?) allow/prevent changing colors?
css.php