Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Space Shooter Tutorial Q&A [ARCHIVED]

Discussion in 'Community Learning & Teaching' started by Valdier, Jan 12, 2014.

Thread Status:
Not open for further replies.
  1. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I'll double check that the "done" project is correct!
     
  2. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Can you post more information? Perhaps with screenshots? I'm unclear exactly what could be causing this issue. It could be due to a number of issues.

    Again, I'd say the best and "closest to hand" solution would be to carefully compare your scene to the "done" scene and see what's different. Look at the components and their values, also look at the scene and see if anything looks different between the two.
     
    sheldon-wang likes this.
  3. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    That's on odd one!

    My first suggestion would be to re-download the project and try to reimport the assets, as this sounds like a corrupted asset of some sort.
     
  4. Urosh990

    Urosh990

    Joined:
    Apr 17, 2014
    Posts:
    1
    Hi Adam,
    I just want to thank you for this simple great tutorial.. I`m familiar with coding in OO languages so i needed just a "walkthrough" for unity, and u did great job. I made i few adjustments to make it more interesting. If i get stuck hope u will help.. Greetings from Serbia..
     
  5. RassenChidori90

    RassenChidori90

    Joined:
    Apr 20, 2014
    Posts:
    1
    Hi I have been Following the tutorial and love it great way to get started with unity but ive hit the same problem as above just wondering if you found a solution to this yet or if its still unsolved ive looked through the done scripts etc and the only differences between my work and the done is the extra work not covered in this tutorial
     
  6. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Can you tell me exactly what stage you are at? Have you finished the tutorials? Are you getting any errors in your logs? Does the "Done" scene build and run?

    All of these things will help us diagnose the problem.

    If the game works in the editor, it should work in the web-player.
     
  7. Valvados

    Valvados

    Joined:
    Jan 27, 2013
    Posts:
    63
    I got stuck on the script tutorial, especially the part where the video skips and switches to a edited in track and then suddenly says movement.

    That took hours to figure out why mine was different.

    Then I get all of that built out, Unity then has "The associated script cannot be loaded" error so I have to close out the whole entire unity and open it again.

    Then I got this error; 'The scripts file name does not match the name of the class defined in the script!'

    Used the same names and locations as you. PlayerController, Assets/Scripts/PlayerController.cs

    Okay ^ edit; Fixed all errors, built it out but my player ship doesn't move with a speed of 10.

    I copied the finished script underneath of the video but now my space ship springs back and fourth when releasing the key which is undesired effect not what I want in my final version of the game. I liked the movement in the video around 8minutes or so.

    Looking at getting a player controller just right for my own non- space shooter game that is 2d view but using all 3d graphics so this tutorial is very interesting to me appreciate any updates help.
     
    Last edited: Apr 23, 2014
  8. nordicorc

    nordicorc

    Joined:
    Apr 23, 2014
    Posts:
    3
    Hello all,

    I am new to scripting in Unity3D, but familier with the editor I work as an designer here in the city by the bay at a shop that users Unity3D, Android SDK and Xcode.

    I have scripted with MEL a ton to make tools in Maya, but mainly have always relied on bashing others work.

    How do coders or scripters know the capability of the classes Unity3D has to offer?

    I am looking through the Scripting Reference Index site pointed out in the tutorial and my mind is blown away that one would know to use Quaternion.Euler to grab rotations to stop form getting gimbal lock.

    When rigging in Maya via scripts or expression editor I never have to call a special enumerations to avoid rotation problems.

    Do coders and engineers open up libraries and just start reading them.? Is this stuff kinda standard across game engines, programming tools and languages?

    Amazing tutorial almost done and commenting in my scripts all over the place!!! I WANT TO MAKE MY TOONS DO STUFF!!!

    Thanks
     
  9. Valvados

    Valvados

    Joined:
    Jan 27, 2013
    Posts:
    63
    Edit; Okay I went through the whole movement tutorial again, after completing the roll ball game tutorial.

    I think I got it this time got my ship moving, intentionally on Y and Z instead of like the tutorial. So I have a side scroller shooter instead.


    :O~~~~~~~~~~~~~~~~~~!

    This is awesome im modifying things with the shooter and they're working :)!!!!!!!!!!!!!!!! I really like this tutorial and game !
     
    Last edited: Apr 24, 2014
  10. Valvados

    Valvados

    Joined:
    Jan 27, 2013
    Posts:
    63
    I'm starting to get the hang of things obviously no where near your level, but I think in the unity verse they use ctrl+' to find things or search and occasionally type something like controller, damage ect. to find what they're looking for. They don't read end to end just what they're working on primarily, also I think a lot of them have read some version of the unity manual.


    Found the problem had a Character controller on my ship... Games working again :p


    edit;
    I got to get to bed.

    Ran into another problem spent about an hour on it.

    I got my Destroy by time script on the explosion completed accurately checked 5x, but the explosions do not get removed from the game the list keeps on going. Stuck on that step, don't want to move on until it's solved.

    Additionally I paused the game, clicked on the explosion and could see the script attached,,, Don't know why they're not getting deleted.
     
    Last edited: Apr 25, 2014
  11. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Valvados: I'm glad you got everything working!

    Let us know if you have any more issues.
     
  12. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Nordicorc: Much of this is simply getting some experience and time coding. When I first came to Unity, I had never coded myself either. It takes some exploration and if there is anything you don't understand, asking not only "how?" but "why?" so it all starts to make sense. I try to explain the Why as well as the How whenever I can. If I missed something, let me know.
     
  13. nordicorc

    nordicorc

    Joined:
    Apr 23, 2014
    Posts:
    3
    Thanks so much really helps, going to try this out tonight at home. I just started laughing at the thought of coders memorizing or studying the library.
     
  14. nordicorc

    nordicorc

    Joined:
    Apr 23, 2014
    Posts:
    3
    Thanks so much Adam I think the tutorial is amazing and I am going to try to finish tonight at home. I want to slap my own art in and add a few features and jam it on my homepage as a portfolio piece. Would you be able to look at one of scripts and just read the comments to see if I am understanding the Why? when I am done?
     
    Last edited: Apr 25, 2014
  15. Valvados

    Valvados

    Joined:
    Jan 27, 2013
    Posts:
    63
    Adam what page is that on Safari in the last video

    It's like a new tab page or home page :O looks cool

    would like to have that on a windows browser or chrome


    Here's; My mod on the game,

    http://youtu.be/UrqWQMXXx5s

    don't think I am going to go any further just going to rip the character controller out for my game and mod it to my needs, really like the game but want to finish other game first before exploring making a shump, which is a pretty dead genre on HD devices so it would make a good game if taken far enough.
     
    Last edited: Apr 26, 2014
  16. GeekGonzo

    GeekGonzo

    Joined:
    Apr 27, 2014
    Posts:
    13
    Just wanted to drop in and say thank you!
    Great tute and I've picked up quite a bit, I used my own assets, and set up my own particle effects for engines/explosions etc... and added some nice parallax effects for the background. I made the asteroids a couple of different enemy ships, and my extended goal is to make them shoot and chase the player.
    All in all, this tute was clear and concise, there was even a bit of humour injected. Very rewarding, and will help greatly in future projects.
    I'm very new to coding(my strength is modelling and animation), and finding a complete guide from start to finish, really helped. It's very hard to piece together info from random tutes on youtube.

    Thanks again! :D
     
  17. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    When I first started using Unity I read the entire Users Manual and Component Reference from cover to cover while I was commuting on the train. (Yes, I actually printed it out...)

    But, that being said, it's hard to read the Scripting Reference. The scripting reference is very much like a dictionary or encyclopaedia. I use it to look up things for reference. There are times, like a dictionary or encyclopaedia, where one subject or page has links to others and I follow them to suit my interest and curiosity. Often scripting reference pages will have links to other similar pages that are worth checking out.

    Take a look at this page on the Box Collider:
    http://docs.unity3d.com/Documentation/ScriptReference/BoxCollider.html

    Note at the top there are links to other related components:
    View attachment 97580

    These are worth following up and looking at as they relate to the Box Collider.

    Also, if you are looking at the Scripting Reference, and need to know more about a Component, follow the link "View component details" to switch to the Component reference:
    View attachment 97584

    Also worth noting - If you are in the Component Reference, you can "Switch to Scripting" to get the Scripting Reference Page:
    View attachment 97583
     
  18. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    You can post the code here and ask any questions you want and I'll look at it when I get the chance.

    Don't forget to use code tags when posting code.
     
  19. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    That's great!

    The entire idea is to repurpose the material and concepts to make something new!

    I'm glad you found the tutorial series useful, and I hope it gets you off to a great start.
     
  20. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Do you mean this one?
    $topsites.png

    This is a feature of Safari, and in recent updates has gone for the "flat" look, rather than the "curved" look. It's simply an optional start page in Safari, where you can "pin" your favourite sites using a mini-version of the page.

    I'm unclear what options there are for this in other browsers...
     
  21. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Thanks for the feedback!

    The "Done" game may also give you insight into one way to make enemies and enemy weapons.

    Scan through the "Done" folder and look at how we did things there.
     
  22. Metushelah

    Metushelah

    Joined:
    Apr 5, 2014
    Posts:
    3
    Hey Adam :D
    I just wanted to update you (and the others in case they too experienced this problem i had with the shots disappearing some distance from the ship) that after i did went over ALL the assets and scripts (i even deleted the comments i made incase they were the culprit) and it still didn't work and they kept on disappearing though in the Done_Scene it was clear that it worked.

    Then i figured out that i haven't looked into my Shot prefab and there was the problem indeed. My shots prefab was "using gravity" and when i turned it off indeed it started working :)

    I would excpect gravity to revert the shots' direction and make it move back but it doesn't, it just disappears.

    Thanks any way, and i hope this helps future us unity developers.
    Cheers
     
    MaxTitkov likes this.
  23. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Met: What it's doing in this case, is making the shots fall away from camera - but with no perspective - you can't tell.

    Try running the game where you can see both the game AND the scene view.

    In our game, the camera is looking down on the game and gravity is in line with the camera view, where "down" is below the player.

    If the bolts are using gravity, then they will fall down, below the ship, away from the camera from the moment they are fired.

    From the game view, as the camera is orthographic: visually, the shots will look the same.

    When they fall so far they are out of the cameras rendering volume (otherwise known as the frustum - which is represented by the gizmo made of white lines) they will no longer be rendered as they are too far away - so they disappear.

    SO! Yes!

    Don't use gravity on any of the objects in this game!
     
  24. Valvados

    Valvados

    Joined:
    Jan 27, 2013
    Posts:
    63
    Yeah the curved version of that, ah I'm using awesome new tab page on my chrome atm its slow but I don't really like it when it fills my new tab with random pages I've visited.

    Chrome has the best overall performance on dual cores or better processors, imo. There's a few things that are faster more compatible in random other browsers though. Chrome has a really high pixel viewing area as well if you keep it tuned properly. That curved new tab page looked pretty neat though.
     
  25. MrE

    MrE

    Joined:
    Apr 12, 2014
    Posts:
    2
    Thank you ,Adam . I enjoyed going though this tutorial alot.
    Taking the project further i put it on my droid device with some touch control's.
    In the process of tinkering with certain things ,i came across something that baffled me and still does:

    All fine an dandy except - when the Asteroids reached where my ship spawned, they bounced off something.

    After a fair while i discover the old CharacterController attached to my player,disabled it ,still the same and started to look elsewhere.
    Eventually using the Done_ stuff as reference ,i removed the CharacterController and all is well.

    Do any of you fine upstanding fellows know as to why this CharacterController provides collision and why it stays at the spawn location?

    Cheers.
     
  26. Valvados

    Valvados

    Joined:
    Jan 27, 2013
    Posts:
    63
    NVM fbx conversion isnt supported by blender yet.... Have to use autodesks free tool.... So many programs lol
     
    Last edited: May 6, 2014
  27. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Was this a CharacterController that you added to the Player Ship? Or are you talking about the Player Controller script?
     
  28. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Yes, you can export .fbx from Blender, but you can't import .fbx files INTO blender. Could be a license limitation?? Unclear! So, yes, .fbx files need to be converted before importing into Blender.
     
  29. MrE

    MrE

    Joined:
    Apr 12, 2014
    Posts:
    2
    Yes, Adam. It was an additional CharacterController component that i added to the finished project while implementing my touch controls.
    Why would This component in conjuntion with the Player/PlayerController cause this voodoo like collision at the ships spawn location?

    I have it sorted as above,but in the intrest of understanding, i seek further clarification. thanks again.
     
  30. Valvados

    Valvados

    Joined:
    Jan 27, 2013
    Posts:
    63
    It says they're working on it in the logs as well as a license issue but I think they're paying for it or something because they're adding the support for it. 2.69 2.70 notes
     
  31. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    It says they're working on it in the logs as well as a license issue but I think they're paying for it or something because they're adding the support for it. 2.69 2.70 notes

    Interesting! As it's open source, I was never expecting .fbx support, but that would be very nice!

    Thanks for the report.
     
  32. Avaren

    Avaren

    Joined:
    May 26, 2014
    Posts:
    1
    Hello Adam,

    First let me say thank you for a great tutorial! It has been much help getting started with Unity.

    After completing this tutorial I took a look at the Done section and noticed the same issue rock.tsai mentioned of page 3. The asteroids that make if off screen don't actually get destroyed.

    I worked out that this is because the Capsule Collider was moved from the parent Asteroid GameObject to the child asteroid mesh to allow for different sized/shaped asteroids.

    When DestroyByContact onTriggerEnter is called, both the asteroid and its mesh is destroyed (as the DBC script is applied to the parent asteroid), whereas in DestoryByBoundary onTriggerExit only the child prop is destroyed (as this is the 'other' collider), the parent object lives on forever.

    How would one go about making the DestoryByBoundary script destroy both the prop AND the parent asteroid? One way I could see is assigning a very small Collider to the parent asteroid, but wondered if you knew of an other way?

    Cheers,
    Avaren
     
  33. ghostj3tt

    ghostj3tt

    Joined:
    May 27, 2014
    Posts:
    1
    Hey Adam. Great tutorial, I'm catching on to Unity very well thanks to your videos.

    My problem is that my ship doesn't shoot. I have checked and double checked every single line of code, I've watched the tutorial on Creating Shots and Shooting Shots and I'm doing everything by the book. I get "The referenced script on this Behaviour is missing!" when I push the shoot button, which by default is left control. I am on a Macbook Pro. I have also watched the tutorials on GetButton and read the manuals and scripts for Input and Input manager. I see nothing wrong. My code is exact and my scene looks just like yours. Any ideas?

    Frustrated, but viewing this problem as a learning experience.
    Jett
     
  34. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I'll have to look into that. There were a few times that we "refactored" the architecture of the game and the "Done" scenes should reflect the final game created in the tutorial, but if it doesn't, that's not good.

    I'll add this to my todo list and if there's a problem, I'll update the package and resubmit to the Asset Store.

    Good catch.
     
  35. jack_kc

    jack_kc

    Joined:
    May 30, 2014
    Posts:
    1
    I was experiencing the same problem. Setting the Asteroid Collider to "Is Trigger" solved the problem. Thanks.
     
  36. Jovaweb

    Jovaweb

    Joined:
    Nov 20, 2013
    Posts:
    1
    Great tutorial, thanks for the effort making it, much appreciated!

    One minor confusion. Building the Web player on a Windows rather than iOS the option to name the build doesn't appear. There seems to be quite a long thread on this on the forums/bug reports.

    Can work around it by naming the folder used to build in to something specific rather than just 'Builds' so it's not an issue but might be worth mentioning in the video as I was confused for a while.
     
  37. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Good point, Jovaweb. I'll try this out on Windows and update the video with an annotation if necessary!
     
  38. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    That was a really, really good tutorial series. Answered a lot of questions I had, cleared up a lot of confusion. I'd love to see more like it.
     
  39. CharmingTroll

    CharmingTroll

    Joined:
    May 24, 2014
    Posts:
    2
    I had the same problem.

    In PlayerController.cs do you have the line:
    Code (csharp):
    1. GameObject clone = Instantiate(shot, shotSpawn.position, shotSpawn.rotation) as GameObject;
    I changed it to the code found in the PlayerController.cs attached to section 14. Audio (http://www.unity3d.com/learn/tutorials/projects/space-shooter/audio)
    Code (csharp):
    1. Instantiate (shot, shotSpawn.position, shotSpawn.rotation);
    I noticed when going through the tutorial that the original line had been commented out. I didn't see when or where that occurred in the tutorial. So maybe it's not there?

    BTW, if you have it with the clone code you will get a warning in console about "clone" not being used. With that error mine played fine in Unity but not when built for the web.
     
  40. CharmingTroll

    CharmingTroll

    Joined:
    May 24, 2014
    Posts:
    2
    Something to note regarding the final step "Building the game". I'm using Unity 4.5.0f6 on Win7 and when I hit Build it asks me for the directory to build in but I never get the "Save As". So if the directory is named "Build" the web file turns out to be "Build.html".

    I needed to name the directory what I want the file name to be. Not sure if that's some weird quirk on my machine, a bug or feature of 4.5. :)
     
  41. Ares121

    Ares121

    Joined:
    Jun 5, 2014
    Posts:
    8
    Great tutorial! Very informative but I'm totally stuck on this one error. I've seen a lot of general posts about this but nothing quite explains it for me. It came up first when I created my shot but I managed to fix it by going back through the vids. I had applied a collider to the wrong object (ya I'm a rookie). Now that I have moved on to "shooting shots" it has come back. I have compared everything, to the best of my knowledge, to the vids and I'm struggling to figure out where the error is. I can't seem to shoot the shots either and since this is the only error that is showing up I think this is why. Please help...this one is driving me crazy!

    Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!
    UnityEditor.DockArea:OnGUI()
     
  42. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    Did you accidentally use a plane for your bolt rather than a quad? I think you did. :eek:

    http://answers.unity3d.com/questions/7841/what-does-the-compute-mesh-inertia-tensor-failed-e.html
     
  43. Chiaro22

    Chiaro22

    Joined:
    May 26, 2014
    Posts:
    5
    Firstly: thanks for a very detailed and noob friendly tutorial series!

    Alas, I have the same error message as Ares121, and for me it appeared after adding the "mover" script during the Creating Shots tutorial. I've double checked the script and I've read a little bit on Unity answers but I'm not quite sure what's wrong. I've also checked most of the steps with adding and removing the colliders etc, but can't find where I've done it wrong. In the inspector my VFX reads as a quad in the mesh filter component part.

    After exiting and re-entering the error message is gone. Dragging test shots into the hiearchy in game view mode works fine.
     
    Last edited: Jun 6, 2014
  44. Ares121

    Ares121

    Joined:
    Jun 5, 2014
    Posts:
    8
    Unfortunately no. I used a quad...which is why I'm struggling so much to find what's gone wrong at this stage.

    The parent "bolt" object has a rigid body, the capsule collider and the "mover" script. The child "VFX" has a quad (mesh filter), mesh renderer, and the fx_bolt_orange texture on it.

    What makes this more frustrating is that I fixed the problem that showed up originally during the creating shots tutorial. Where it came from now has befuddled me because I have not made any changes to the meshes or colliders at the next step "shooting shots".

    When I re-launched unity today the error is no longer in the consol but the shots wont fire. So I feel like the problem with the above mentioned error is persisting.
     
    Last edited: Jun 6, 2014
  45. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    Well, you'll have to do some experiments to figure out where the problem is. Drag instances of the shot into the window, see if that works. Try creating a dummy object like a cube with your instantiate script in playerControl. Somewhere, your program has an error. I've seen that mesh tensor error many times, usually it "goes away" all by itself without me changing anything.

    There's a perfectly logical explanation. Trust me.
     
  46. Ares121

    Ares121

    Joined:
    Jun 5, 2014
    Posts:
    8
    Thanks, I will try the dummy object to test. Dragging instances of the shot into the window has been working since I corrected the first issue. The shot does indeed do what it should. It won't fire from my ship though....and I've gone through the script line by line with no errors. Consol shows no script errors also....just the tensor error.
     
  47. Ares121

    Ares121

    Joined:
    Jun 5, 2014
    Posts:
    8
    Well I should have paid more attention to the post where Adam says to check it against the "Done" assets. Once I did that I could see my error. Turns out I missed an upper case letter in my script to instantiate the bolt. That's what caused it not to function. The other error seemed to have fixed itself just like you said Misterselmo. Thanks for your input on my problem. It was a helpful reminder to keep testing.
     
  48. Ares121

    Ares121

    Joined:
    Jun 5, 2014
    Posts:
    8
    Hi Jett,

    My problem with my ship not firing turned out to be a small error in my script. I missed the uppercase U in: void Update ()
    I had accidently put: void update (). Took me a long time to notice it. I spotted the error when I compared my script to the "done" script. Hope this helps!
     
  49. RJ-MacReady

    RJ-MacReady

    Joined:
    Jun 14, 2013
    Posts:
    1,718
    Your entire program was interrupted because you didn't press the Shift key, and because you are allowed to make a method of virtually any name you so desire and because there is no requirement for you to supply an Update () method for the game to run. Chasing down these little tiny problems, these "bugs" in your code, that is going to be a big part of your life going forward. You will catch the same bug much more quickly next time, hopefully. I guess that's called getting better.

    ...also, as you experienced, comparing to the "done" script as per the instructions helped you. The instructions are there for a reason, to instruct. They were written for the sole purpose of making your life easier. :)
     
  50. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Ares:

    If you can post a screen shot of your hierarchy and screen shots of the GameObjects in the inspector, that will help.

    There are two worlds in Unity that must work in sync with each other. The code in your scripts, and the way your scenes are assembled.

    You may find that your scripts are correct, but they are placed incorrectly - or the components are incorrect or misplaced or misconfigured.

    Let's try to get an overview of the entire thing.

    Post the GameObject (as a screenshot) that is throwing the error. Post the script driving it.

    We'll get to the bottom of it.

    And don't forget the "done" folder in the project, which is good to use for comparison. See if your project matches the "done" project.
     
    Last edited: Jun 12, 2014
Thread Status:
Not open for further replies.