Luke Frohling

Writer / Game Developer / Educator / Actor

Tutorial – Unit 6 (next steps)

Thankfully this is the last section. I’m happy to have done this course but listing it at 36 hours when it was closer to 80 might have been advisable (maybe it was listed at 72 I don’t remember). Whatever the case it covered a hell of a lot so far and I’ve got another chunk to go.

I think I just saw that I can create a script that other scripts inherent from (by using the “protected” (instead of public) command. I can definately use “const” and “static” and “readonly” as variable keywords. Static sounds like it could be more global… Event functions? Update is an event function. FixedUpdate is called before Update function and useful when dealing with physics while LateUpdate is good for camera positions as they follow the camera. Ah as this will put the camera there AFTER all the physics calculations/adjustments (hence less jitter). Awake is run before Start which might be good in some cases. Object pooling is a useful way of saving processing power (don’t have to create and destroy unlimited objects)- which makes sense for some processors but it won’t matter for anything above iPhone 1 I would think…

People in the comments suggested I do a 10 min tutorial (https://learn.unity.com/tutorial/introduction-to-object-pooling?tab=groups#) on it instead of relying on a cut and paste code. Wow, using a child object as a centre of mass for the parent (in the car) is mindblowing – I was too tired to really appreciate it the first time I saw it.

I just put music into my game and will be using (https://answers.unity.com/questions/783631/keep-audio-playing-even-though-i-reset-the-scene.html) in order to keep the music playing and not restarting even if I have to do a scene restart 🙂 I’m testing the following code:

public AudioSource bgm; // link this with a bgm prefab, add tag "BGM", loop, don't play on awake
 
 void Awake() {
     GameObject currentBGM = GameObject.FindGameObjectWithTag ("BGM");
     if (currentBGM == null) {
         AudioSource spawned = Instantiate (bgm);
         spawned.Play ();
         DontDestroyOnLoad(spawned);
     }
 }

Let’s see if it works… Yes! OK back to the tutorial. False friend alert → % is an operator that gives the remainder to an equation. For example 30/30 would give 0 while 31/30 would give 1 and 32/30 would give 2. I’m not really sure how 6.2 gives the impression of changing gears to the viewer but I guess that’s not important right now. 6.3 – the use of a list to keep track of all the wheels might’ve made my game easier to conceptualise and code (as to keep track of all the pipes). But I can also see the wisdom of learning one thing and making one game with it and learning while I go. Hence I would already release my game into the wild if I knew how to do it (and I didn’t feel the tute is going to direct me there anyway so I better just wait for a bit). I like the way the list is used in a foreach void loop with a nested if statement. I like the way he changed it to a bool and so it could return true or false.

Aha! Now onto sharing my project 🙂 Lesson 6.3. I like how this tute is structured – I just wish I could stay focused on it so I could finish it quicker. OK, it works and builds but it needs some more basic buttons to be bearable. Firstly a quit button (on Game Over and You Won screen) and music and sound effects toggle switches on title screen (on the bottom). Also Have to rename the created file from P.Project to DrainCleaner-MyFirstGame. I would like a windowed option as well as a full screen option too. I’d like the Audio’s to be toggle switches (Turn music off & Turn music ON!) (Turn sound fx off & Turn sound fx ON!). OK, well the quit button works.

This page helped me make a mute project (https://docs.unity3d.com/ScriptReference/AudioSource.html) but it’s not helping me with my project just yet as it’s a prefab with the tag of BGM that I need to mute. This page (https://docs.unity3d.com/ScriptReference/AudioSource-mute.html) might be more useful… Nope I’ll do this much later- interesting about the mixer info- I might use this to group all sound effects so I can turn them all off in one script,

Facebook
Twitter
LinkedIn

Featured Post

Outside

During the week I’m consumed at work –…

Manager

I’ve been a manager for Ready Team One…

Hand Tracking

Continuing from last post and I took the…

Hand Tracking

Tales from the battlefield continued. I’ll try this…

Forward

Frustrating. I’ve spent days trying to get Link…

Fixed The…

This took weeks. First problem was the cable…

Give Me…

Trying a new tutorial as the other ones…

VR (and…

VR / AR Direct: https://www.roadtovr.com/ – Computer news…

Geoff’s Way…

You may need to check previous posts to…

Scroll to Top