Video Tutorial: Moving Platforms in Unity 2019

Hey guys, I made a video tutorial to start preparing for a class Ill be teaching in January. If you guys could take a look and give feedback I’d appreciate it. Hopefully it can also be useful!

right in the beginning, you say that using animation system is labor intensive and say you using something else instead. then you jump directly to step by step.

But what is this alternate system you are using? Why specifically? what is it going to accomplish. Whats the general workflow we are gonna follow?

If that’s explained up front then it’s easier to get engaged with the step-by-step because you can think ahead and figure out why we are doing things a certain way.

Hey thats awesome feedback - thank you. Ill be sure to include information in my future videos when I make claims like that.

In this case, using the animation system requires you to manually rig each platform and record an animation - for a scene where there might be dozens or hundreds this can take hours or days to get it right.

What I’ve proposed here is a script based system in which platform pathing, speed, and automation are easily manipulated, modified, and can be implemented repeatedly without rework.

1 Like

yeah sounds smart. i just still in the phase where i do lots of tutorials and its always a lot harder if author jumps into the step by step without thoroughly making sure you understand the problem you are trying to solve first. In fact sometimes its even useful to intentionally walk through the wrong way so that its easy to conceptualize what a better way is gonna be.

Generally speaking it’s a good tutorial but if you’re looking for some specific improvements I saw a few things that could potentially be changed/reconsidered.

  1. Whilst I agree that using a script to move the platforms is much easier, your claim that “In this case, using the animation system requires you to manually rig each platform and record an animation” is incorrect. Why would you have to manually rig what is essentially a flattened cube? What are you doing… rigging a cube with FK/IK? Again, animating this would be pointless but it wouldn’t require actually rigging a cube. I bring this up because, if you’re teaching people new to Unity, it might give them the wrong impression (ie- they have to rig everything to animate it… even a basic cube which isn’t true)

  2. You’ve missed an opportunity to talk about texture atlasing and GPU instancing a texture atlas that is utilized by non-static objects. This is something that should be considered under optimisation/performance/best practice. However, the topic of a texture atlas might be too complex depending on who you are teaching. I think it’s worth mentioning.

  3. Your file naming convention is wrong and teaches a bad practice. PleaseUseStandardPracticeForScriptNames.cs

  4. Your variable/parameter naming convention is wrong and teaches bad practice.

public int point_number [incorrect]
public int pointNumber [correct]

  1. Your formatting is a little inconsistent. The “if” statement in Start() has no space after it but the “if” statement used in Update() does have a space after it. Your “if” statement in MovePlatform() has no space, etc

  2. You’re not static batching static objects that share the same material and have the same mesh. In fact, you don’t mention this at all.

  3. I’m curious how your system works when the player can jump. For example, if the player jumps into the trigger but then back onto the original (non-moving) platform… the player would be parented to the moving platform (that they are not standing on) and, presumably, this is not what you want. It might be worth considering this issue if you are teaching people as they will most likely want some kind of jump mechanic.

Thanks for your feedback @Anaxis_Studio ! To answer a few of your points:

  1. ‘rigging’ may not be the best word - using the animation system for moving platforms requires you to manually move the platforms in the editor and set keyframes for each ‘stop’ for each platform, with a different animation for each. This gets out of hand quickly with large numbers of platforms or other objects that dont move in a uniform way.

  2. and 6) these are beyond the scope of a beginner tutorial

3-4) snake_case is just as valid of a naming convention as camelCase - in fact, you use it in your username! The important thing is to be consistent! Snake case - Wikipedia

  1. Thats a typo, thanks for pointing it out.

  2. this works fine. Leaving the collider un-parents the object as you would expect.

1 Like

Does it? I animate stuff directly in scenes in Unity from time to time, and I’ve never done anything I’d call “rigging”. I agree there are better ways to make moving platforms, but this is not why I’d avoid that particular approach.

As I said in the previous post, calling it rigging was an error. You can reuse animations sometimes but Ive found them to be tremendously time consuming to use for scenes with lots of moving parts because of the amount of manual work involved.

lol yes I use it in my name but if you check all of the default scripts from Unity they use camelCase so I can only presume that is the “recommended” way. Not that it matters but there was not really much in your video to critic so everything I mentioned is really more of a different of opinion that “100% wrong”.

You can argue that it’s down to personal style but your way of doing it is not recommended by Microsoft afaik (in fact, they go as far as to say don’t use underscores). Additionally, Unity also follow the convention of camelCase so I can only assume it’s best practice.

https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/capitalization-conventions?redirectedfrom=MSDN

Whether this matters to the people you are teaching is another question, especially if they are totally new to programming/Unity.