Some comments on the Platform tutorial

I’m a new user of Unity, and have started working through the 3D Platformer Tutorial as a learning exercise. So far, I’ve worked through the “First Steps” chapter. I’ve encountered a few issues; it’s probably best to keep my neophyte status in mind as I present them.

The points I stumbled on are:

  • Lerpz animation is problematic. When running the game, the arms-out falling state is activated and deactivated repeatedly, making Lerpz look like he’s flapping his arms trying to fly. After running around, the animation can start to behave correctly, but doesn’t necessarily stay that way. This doesn’t seem to affect the game play or the progress of the tutorial, but is pretty ugly. Admittedly, it is also amusing watching Lerpz flap his arms right before you hit jump and watch him take off…
  • The description of the Fallout Death script seems to assume that the re-spawn behavior is already established. This leads to unanticipated exceptions when Lerpz dies.
  • The discussion of re-spawning is a bit imprecise. E.g., placement for Respawn2 and Respawn3 is not specified, the discussion of re-spawn points just trails off in mid-sentence on pg. 38, etc.
  • Respawn behavior produces an error “AL_INVALID_VALUE in ‘Respawn1’”. Apparently, it is caused by “audio.Play();” on line 97 of the Respawn.js script. This occurs whenever a new Respawn is made active.

Points 2 and 3 are more for completeness. I am curious to learn whether others have encountered the issues I summarized in points 1 and 4, and what solutions might be appropriate.

Maybe I should add my notes here.

First of all I want to say that I love this tutorial, I think it’s a great tutorial and I appreciate it a lot - and it’s obvious what a tremendous amount of work went into that tutorial …

… but I think a few improvements might still be possible :wink:

I’m not sure, maybe I should add this as a bug report? I would wait until I finished doing the tutorial, though…

Tutorial “Main Camera”, Project: “NearCamera”

Lots of Warning messages: “Texture size is not power of two in GUI stuff” (would be nice if that could somehow be switched of, I find it a little confusing here even though it’s obviously “as designed”)… I’m mentioning this here, because it might confuse a new user who’s just opening the tutorial project and might then think “there’s something broken in the tutorial”… it might be enough to just mention those things in the tutorial for clarity (something like “don’t be shocked when you get message XY when you open the project, this is because of Z and is no reason to worry”)

p. 15: Breaks prefab connection (would be nice to have that written down explicitely to avoid confusing new users, I think it’s mentioned before, and when I remember correctly explicitely stated later, but there on page 15 I had the feeling it was kind of missing)

p. 24: “if the are moving” → “if theY are moving” (just a typo, y in they is missing)

p. 25: Color values of Jet Light would be nice (this is wonderfully done in the particle system - now we expect this cool way of doing it for all colors :wink: )

p. 25: The “Jet”-Prefab already was in the Player folder…

p. 34: I’m getting a MissingReferenceException in the SpringCamera script when I fall down… Reason is because I didn’t attach the ThirdPersonStatus-script to the player (which is done on p. 38 of the tutorial). Still doesn’t work because as it seems, Respawn.currentRespawn is null (which is solved on p. 37 of the tutorial)…

… that is one thing I noticed a few times during the tutorial: sometimes the order of things seems a bit beta :wink:

p. 36: Position of RespawnPrefabs is kind of hard to find (image only shows first one, and from the image, I don’t really know where that is - this is because the screenshot is taken with more textures than the actual game project currently has - hm… for some reason the textures show now, so maybe it was just some setting being wrong - the first time I opened the project, most of the textures were not displayed, don’t know why that happened, sorry)…

p. 37: Assigning a Respawn instance to the Prefab doesn’t work in any of the described ways (this may actually be a bug in Unity, or maybe a problem with my installation… see below for another instance of this with more details)…

p. 38: Ends with “We will return to this script in chapter on”

p. 46: The JumpPads aren’t strong enough to make Lerpz jump high enough (in the 3 “elevators”), I think 15 instead of 5 might be a better value

p. 49: GameObject “Level” existed already

p. 49: GUISkin “LerpzTutorialSkin” existed already

p. 54: StartMenuGUI.js exists already…

… all the following scripts already exist in the project… Suggestion: Maybe rename the scripts that come with the project, OR: Change names of the scripts in the tutorial (latter might be easier).

p. 70: Add a sentence to remind the user of adding the other lasers by creating a prefab and dragging / positioning that prefab into the level.

p. 70/71: The exercise might better be placed after the next part, when the user doing the tutorial has learned how to do it. The way it’s placed right now, the user might actually not think about it anymore when he’s finally found how he could do it…

Script Lasertrap: Sets laserWidth to 12 which makes the laser to wide (should be 8).

HitEffect was missing (needs to be dragged from Props - which took me a while to find out :wink: )

p. 73: CopperNew is now called Copper! Actually, it seems that CopperNew is missing because all the Scripts are already attached…

p. 74: I think this is a bug in Unity: I can’t drag the player game object on the Prefab (I’ve had that before while doing this tutorial). I can only do it to the instance of the prefab - but when I try updating the prefab with the change in that instance, it has no effect.

p. 74: The script “ThirdPersonCharacterAttack” must be added to Player or he can’t beat the robots up (that information is missing in the tutorial, or I’ve overlooked it :wink: ).

p. 76: The trigger collider component is not automatically added (at least it wasn’t for me)

p. 76: The Copper-Giszmo name must manually be typed in…

p. 77: More elegant than copy’n’paste is “duplicate” (cmd+d)… on the other hand: Why not use prefabs for this?

p. 85: It’s not “Scenery” in the hierarchy, but “levelGeometry”

p. 86f: The sounds had already been added to the scripts…

A few things one might consider bugs or missing features in Unity I stumbled upon while reading the tutorial:

GUISkin CustomStyles Name only accepts small case letters…

Project → Create (or RightClick): Menu should have “Scene” to create a new scene.

Bug: Create a scene, save it. Then drag’n’drop scene to other location => scene is duplicated!

Inconvenience: The wire-frame representations of colliders are drawn over the OpenGL models which makes it very hard to position colliders (on a Mac Pro, ATI Radeon X1900 XT).

Documentation: An overview of all default keyboard shortcuts would be very helpful!!!

Jashan[/i]

I’ve just finished the tutorial… I think it’s a lovely tutorial, but my feeling is that the way it currently is, there’s a few things that might actually be frustrating to a new and inexperienced user. I’ll just add my notes here for completeness and I guess I’ll file the whole thing as a “bug report”:

p. 98: The timeline is somewhat tricky for newbies. As there’s 60 frames per second (just like there are 60 seconds per minute), the 0:10, 1:00 etc. descriptions are really misleading. 0.10, 1.00 would actually be much better. What makes it worse is that the tutorial refers to 4.0 and 16.0 which doesn’t exist in the timeline at all. So it should be 4:0 and 16:0 in the tutorial, or even better: 4.0 and 16.0 in Unity (but I guess changing the tutorial is the quicker solution for now unless Unity 2.0.2 is soon to be released :wink: ).

It would be nice to mention in the tutorial that it’s possible to drag the keyframes with the middle mouse button (I just found that out by reading the reference manual). It’s not really intuitive to use the middle mouse button (actually, I can’t really use that at all, since I’m using the middle mouse button for Exposé) and not knowing that I messed up my scene quite a bit.

Argh… That keyframe-system is not really nice. I would expect the first keyframe to remain where it is - but when I delete all keyframes except for the first one and then move to the first one, unfortunately the space ship is somewhere in space, but not in the location where it was in the first key frame. And worse: Undo doesn’t work with that, either :frowning:

And even worse: It seems I can’t delete a keyframe without selecting it. So I really have to remove the animation component, deselect the spaceShip, re-select it (otherwise the timeline doesn’t reset) and start from scratch…

I would say the animation-timeline is that worst part of Unity I’ve seen so far…

What I’ve also noticed: When I only create those 3 keyframes, the spaceShip does a rather weird movement by first going backwards. This is obviously due to some spline interpolation (or whatever is used there).

p. 102: The step “attach the script to the spaceShip object” is missing (it’s mentioned before, but the actual step / action is missing)

p. 105: robots by making the pop into existence → robots by making them pop into existence
M is missing in theM

Has anyone been able to successfully take the knowledge from this tutorial and actually apply it to their own project? I tried doing it after going through the tutorial and could not get it to work. I followed exactly as the tutorial outlines and it does not work at all. It seems to only work inside that Lerpz platformer file. I’m getting all kinds of error messages like “can’t find instance reference of object null” or something like that. It also keeps asking for animation clips named exactly like the Lerpz characters clips, but even after renaming all my animation clips to match the names in the controller script it still does not work. Please help. All I want to do for now is just get the third person camera controller to work with my character (not Lerpz).

I have attached a screen snap shot of the exact error message that is driving me mad trying to get rid of it. It reads:

NullReferenceException: Object reference not set to an instance of an object
SpringFollowCamera.LateUpdate () (at Assets/Scripts/Camera/SpringFollowCamera.js:44)


It appears to have something to do with the SpringFollowCamera.js script

Please forgive me for not understanding all the scripting required to get this 3d Platformer tutorial to work on another character other then Lerps (but isn’t that the whole point of the tutorial… to be able to recreate it yourself??). I have read the scripts (Third Person Controller SmoothFollowCamera) several times and they are a bit or quite a bit over my head… ie more advanced then basic JavaScript. Please help! I’m desperate to get this to work.

I’m going to the GDC conference in February and want to be able to show off what Unity can do with my own third person platformer game demo but if I can’t get the controller set up to work then I’ll have to demo it as a First Person Controller which is not what I intended and changes the whole game concept. I want to create a game demo similar to the Lerps tutorial but using the new Terrain and other things I’ve created in Maya for the sets.

Also, I tried recreating the Near Camera and Far Camera, but that is also not mentioned anywhere in the tutorial?? How is someone new to Unity supposed to figure out how and why you are nesting cameras and renaming them if you don’t even mention that step in the tutorial?? I’m really frustrated at this point and really wish that this tutorial was put together without soo many things missing, incorrect or unexplained fully. The concept for this tutorial is just what I’ve been looking for, but it falls short of being successful if I (or anyone else) can’t recreate it in my own projects.

A null reference exception means exactly that: you’re trying to refer to an object that hasn’t been defined. Take a look at lines of the scripts it telling you about and see what references you need to make.

I understand your frustration, but you might be trying to leap into the deep end of the Unity pool. I know how tempting that is! As you say:

I had a look at an earlier version of tutorial a couple of months ago and it seemed pretty straightforward and in-depth to me, but not something that someone who’s just starting out with Unity would be able to understand all of. I don’t think it’s aimed at absolute beginners, though: an entire third-person platformer is, after all, not trivial. I remember looking at the FPS tutorial a week or so after getting Unity myself, and the scripts didn’t really make a lot of sense to me at the time. After a while, however, everything became completely understandable, and I could take bits of it as I needed and use it in my own stuff.

My suggestion would be to try some simpler scripting to start out with. Even if you don’t understand all the scripting in this tutorial at first, I think it’s useful to use it for some directed instruction for working with Unity, so at least you get more of an idea for how objects interact. Then once you understand the scripting more, you can go back to it and it will make more sense.

–Eric

Thanks for responding. So far I have gone through the following tutorials:

Gui Basics
Marble Tutorial
Scripting Tutorial
3D Platformer Tutorial
All video tutorials online

I have also scoured through the manual (that has no search feature), read tons of articles on this forum and watched several of the Unity San Francisco conference videos. I was able to create my own Marble game after completing the Marble tutorial and I was able to create my own terrain with trees and grass after reading the manual, but this 3D Platformer tutorial has seemed to have gotten the best of me. The only tutorial I haven’t done yet is the FPS tutorial.

Has any advanced Unity user made even a simple Third Person Platformer game yet using the scripts from this new 3D Platformer tutorial? It’s one thing to go through a tutorial, but it’s a completely different animal when you apply what you learned to your own project.

The reason I ask is because I think would really benefit from (ie…learn how to do it myself) if I could review a simple basic third person character walking on a simple plane or flattened cube… nothing complicated. I just want to get the character walking and the camera following the character. I can add all the other bells and whistles later. Can anyone provide me with a simple example package with something like that? I think there is just so much going on in the 3D Platformer tutorial that it makes it difficult to figure out what’s missing or what I’m doing wrong. I know the scripting involved in this tutorial is more advanced, but I really want to understand how to get it to work.

The scripting reference does…I wouldn’t survive without it. :slight_smile: Did you take a look at this?

–Eric

I tried that example and got the same error message:

NullReferenceException: Object reference not set to an instance of an object
SuperMarioController.UpdateSmoothedMovementDirection () (at Assets/Scripts/SuperMarioController.js:29)
SuperMarioController.Update () (at Assets/Scripts/SuperMarioController.js:64)

And yes I looked at the line of code that it refers to and it doesn’t make sense to me as this is the line of code that it refers back to:

line 29: var cameraTransform = Camera.main.transform;
line 64: UpdateSmoothedMovementDirection();

And those two look very similar to the error messages I was getting with the third person controller script.

How could the camera be a null reference?

If it can’t get the reference, then cameraTransform is going to be null. As the docs say about camera.main: “The first enabled camera tagged “MainCamera” (Read Only). Returns null if there is no such camera in the scene.”

–Eric

I figured it out on my own! I must be learning! The problem was this:

I didn’t tag my main camera “MainCamera” and if you don’t it returns a value of null !!

I found it in the scripting manual:

Camera.main
Scripting > Runtime Classes > Camera

static var main : Camera
Description
The first enabled camera tagged “MainCamera” (Read Only).

Returns null if there is no such camera in the scene.

I knew that if I didn’t give up I was on the verge of a breakthrough and I was! Thank God I figured that out because it was driving me nuts! Hopefully I can save someone else the grief I encountered trying to get this to work.

Sorry Eric, I didn’t even notice that you beat me to it! Either way it works now. Thanks so much for all your help and support. I really really appreciate it!

I know this was mentioned previously in another thread but I thought it was important enough to reiterate. Google has a terrific feature that lets you search sites and even reduce search hits with a complete path in a site.

For example go to Google and type site:unity3d.com followed by what you want to search for and it will return only those items matching at the unity site.

To be even more specific and avoid forum postings, use this in Google with terms you want to find in the documentation: site:unity3d.com/support/documentation/ “searchterm” (replacing search term with a word or exact phrase you want to find in the docs)

Here is a sample of the results when searching for the term “null reference” which shows a well commented script which checks a reference to make sure it isn’t NULL before use, which might help your debugging.

The only other pointer I can give you (one of the first things I was taught as a programmer a long time ago) is that when given a list of programming error messages, it is rarely the error at the end of the list causing your problems, because the program doesn’t stop trying to execute after an earlier error occurs.

Hope that helps for future debugging.

Ricko``

Thanks Ricko! The Google search is a great help. I didn’t know I could use it for the documentation as well so that’s really useful to know.

Yes… I’m doing it all the time. It really depends on what you mean by “knowledge”, though. To me, completing the tutorial and gaining the knowledge available in that tutorial means reading and understanding every line of code that’s in that tutorial. If some of the code is not understandable, look it up in the scripting reference. It also means that you have to play with the code for a while. Make changes, see what happens by making those changes (just reading and understanding is usually not sufficient to be able to create something like that yourself - but that’s where you want to go, that’s where it becomes pure joy). If the code is still not understandable, ask in the forum, about the specific section of the code you don’t understand.

It also means changing the original game significantly. Make it behave differently, add some stuff and ideas of your own. Maybe create your own “Lerpz-Level” with some of your own assets. Every once in a while “dig deeper”. Keep in mind: Knowledge is power…

This approach is a good way to learn, and when I remember correctly, that’s also stated explicitely in the intro of the tutorial (not exactly the way I described it here, but somewhere along those lines)…

Obviously, that will take much longer than just going through the tutorial text itself and finishing the “minimal version of Lerpz” (and that alone took me about one full day, i.e. 8 hours). But that is the way to gain the knowledge that this tutorial offers.

I think if you really want to get as much out of this tutorial as you possible can, you should plan on taking 3 or 4 days. I didn’t do it that way, but I go back to the tutorial, when I feel I need to (which I think is more efficient than trying to swallow it all at once - but I guess that’s just personal preference). The way I approach it is to first read the text again, if I feel I want to do something the way it was done in the tutorial. Most of the time, that’s enough. If that is not enough, I open the project and look the relevant sections up in the project - and that might include digging into the code.

Learning takes a lot of time, and trying to rush it is what usually creates frustration (you can ask me - I have been incredibly frustrated by making the mistake of trying too much too soon without taking the time to gain solid knowledge first quite a few times… basically, I guess you could say this happens to me all the time, so I probably have an idea of how you feel about this).

I would say that creating a tutorial like that is quite a difficult challenge, and it’s done quite well already, even though I believe there’s still some room for further improvement (which is why I’ve sent my “bug report” to UT, which hopefully helps them help us :wink: ).

Jashan

Jashan,

You are absolutely correct. I could use to go through that tutorial about 5 or 6 more times to fully comprehend everything in it… and I intend to do just that. I just rarely get 3 to 4 days where I can just focus on Unity so I end up doing a couple of hrs every day or so.

I was up till 5:30am last night determined to figure this out and get it to work and I was frustrated as hell, but I know from prior experience that when I’m really frustrated that means that I’m on the verge of a breakthrough and I need to keep moving forward.

Discovering the cause of that horrible Null Reference error message allowed me to sleep well last night, but then of course something else went wrong. After finally getting my own third person character to walk and have the camera follow him I realized that sometimes when I press the jump button while moving forward the camera does this weird thing sort of intermittently… it jumps inside the character for a split second to the point where i can actually see the inside of the characters eyes and teeth (kind of creepy) and then dolly’s out to the normal distance behind the character. So if I keeping pressing the spacebar (jump) while pressing the up arrow (forward) this keeps happening to the point where i start to get dizzy after a while because the camera is going in and out so fast. It’s very strange and doesn’t seem to happen every time I press these keys, but 3 out of 4 times. Any ideas what this could be? Maybe the camera clipping plane or something to do with the jump speed? I tried adjusting both with not difference.

Hi Joey,

I don’t really know why that happens, but one way of finding the solution may be setting up a “simple case” and adding things step by step. As far as I recall the camera script in the tutorial is rather complex, and obviously, 3rd person platform game camera handling is a non-trivial task.

It might help to start off very simply, just a camera following the character “fixed set behind the character”. Then add some lerping stuff etc., you might actually copy those parts from the original script. The cool thing about this is by doing that, you also get a chance to double-check what that specific code does…

For me, it was really helpful to convert stuff from JavaScript to C#… but that was primarily because I simply don’t like JavaScript. Personally, I don’t think JavaScript is the ideal language to learn things, anyways, due to its loose typing (in C# code, I always immediately SEE what classes are used etc. etc.) - I must say I’m so happy coding C# in VS.NET 2005, with all the code completion comfort… in fact, even though C# is said to be much more verbose than JavaScript, I’m pretty sure I type lot less (exactly because of code completion / intellisense).

Btw, did anyone manage to put the Unity scripting reference to VS.NET F1 (i.e. integrate it into the help system somehow)? That would be neat :wink:

Jashan

Hi Jashan,

Yeah, your right. That’s a good idea. Keep it simple at first so I can isolate the problem. I do have a lot going on in my game demo at the moment. I think I’m getting addicted to this. All I want to do is keep building it, making it better and adding more stuff to make it a fun game to play. Unity is really amazing. I haven’t had this much excitement about a piece of software or computer since I was a teenager fired up about the Commodore Amiga 1000 computer and the Atari 520 ST (the only computer EVER…even to this day to come with a built-in MIDI interface!). You can tell I’m a computer nerd.

The longer you use Unity and the more you learn it, the worse the addiction gets. :wink:

–Eric