C# Bootcamp for Unity

C# Bootcamp for Unity

So you’ve just started scripting in Unity, why not try C#?

If you’re new to Unity or you’re just new to scripting C# then this course is for you.

Overview

Get a brief overview of what you'll learn in this course

Programming Fundamentals

Learn the basics of programming with variables and functions

Test your knowledge

Time to test your knowledge of C# thus far

Using C# in Unity

Now we can dive into using C# within Unity

Test your knowledge

Now lets test your knowledge of C# in Unity

Even more C#

Lets script some particles, raycasts and physics forces.

Test your knowledge

Decipher the errors in this final test script

Conclusion

Some final words on how to proceed

So you’ve just started scripting in Unity, why not try C#?

If you’re new to Unity or you’re just new to scripting C# then this course is for you. If you’re looking to get your “hands dirty” and start creating scripts then this is the course for you.

This course will go over the basics of using C# in Unity and is aimed at beginners with little to no experience in scripting. Unlike other typical programming courses this will go from the very basics of learning scripting then going into creating a script in every single video.  Rather than delving too much into theory we’ll focus more on creating short and basic scripts that you would use in an actual game.

Focusing on creating one specific script for one specific function in each video we’ll show you how to build something that you can use in your own projects. It’ll also build a nice set of scripts that you can expand upon.

By the end of this course you’ll be able to write C# scripts for:

  • Calculating distance and applying force with a raycast
  • Manipulating a particle system
  • Creating health bar UI system
  • Simple Pickups
  • Moving a game object with mouse and button inputs
  • Zooming in with a camera component
  • Teleporting game objects across a map
  • Shooting projectiles
  • Basic Mecanim and Legacy animation systems
  • and much more…

More importantly you’ll gain experience by creating simple scripts that control a multitude of different things.

I originally started off in Javascript aka Unityscript so if you’re coming from that side then don’t be afraid to switch over to C#.

This course will be using Unity 5 beta, but this is not a requirement nor is having Unity Pro in order to complete this course. The main reason for doing so, other than it’s awesome, is because of the API updates in Unity 5.

Prerequisites for this course

This course solely focuses on scripting within Unity using C# so having a good understanding of the Unity interface in general will help a lot. I’d recommend you check out the Unity Basics course here.

Nonetheless everything will be covered step by step so don’t let that deter you.

So you’ve finished the course, now what?

Well it’s time to flex those scripting muscles by going into more intermediate courses on this site. If you liked this course, check out some of my other content here on Unity Cookie:

Creating a Stat Tracking Inventory System

Creating Floating Damage Points

Creating a locking weapon system

Lesson Questions and Answers

Ask a question and get an answer!

Submit your Question
  • Replies: 0

    Hello Jonathan, Is this course updated for 5.6? Just checking. If it is not, will you be showing us how to update for newer versions?

    3 months ago

  • Replies: 2

    Hey Jonathan, when is the updated version going to be uploaded? Is this the updated version?

    5 months ago

    • Replies: 1

      Updated version of what?

      5 months ago

      • You said in another comment here “I’ll need to update this lesson to make it applicable to Unity 5.3.” I wanted to clarify since I can’t see when you uploaded the video, it could be the updated version.

        5 months ago

    • Replies: 1

      I believe you’re referring to the comment about the particle systems. It was updated a while back, here is the lesson: https://cgcookie.com/lesson/scripting-shuriken-particle-systems/
      The old lesson was replaced.

      5 months ago

      • Sorry, I thought it was this one, my bad. Thanks!

        5 months ago

  • Replies: 2

    Hello! Thanks for all the lessons. I’m trying to make a raycast visible in the game window using line renderer, but I’m not having much luck. Any tips? It literally just needs to be a basic line from one vector3 location to another (like we do with a raycast), but I’m not finding it to be that easy.

    7 months ago

    • Replies: 0

      Here is what I have:

      7 months ago

    • Replies: 2

      apparently you can’t shift + enter! oops! public class raycastDistance : MonoBehaviour {

      public GameObject toThis;
      public LineRenderer tapeMeasure;

      // Use this for initialization
      void Start () {

      toThis = GetComponent ();

      }

      // Update is called once per frame
      void Update () {

      Vector3 raycastDir = transform.TransformDirection(toThis.transform.position – transform.position);
      Physics.Raycast(transform.position, raycastDir);
      Debug.DrawRay(transform.position, raycastDir, Color.green);

      RaycastHit hit;

      if (Physics.Raycast(transform.position, raycastDir, out hit))
      {
      Debug.Log(“The distance is ” + hit.distance);
      }

      }

      7 months ago

      • The line renderer allows you to specify the points starting with 0. So you’d have something like “tapeMeasure(0, transform.position)” which would be the origin of where the line renderer starts. Then the second position could be “tapeMeasure(1, hit.point)” which would be the point where the raycast hits an object. Here is an older video that discusses another way to do it as well: https://www.youtube.com/watch?v=hUg3UfE186Q

        7 months ago

      • Got it! Thank you!

        7 months ago

  • Replies: 1

    Hello. It says this course is for people new to scripting with C#, but is it aimed at complete beginners? I have zero knowledge in programming, but I’d like to learn it for Unity. I ask because I have come across many sources that claim they are for beginners and then it turns out you need at least some prior knowledge of programming beforehand.

    8 months ago

    • Replies: 1

      Yes this course is aimed at beginners. It starts with learning what a variable is, then functions, then specifics about things like components and how to access them in your script. It also covers basic debugging and troubleshooting of scripts.

      8 months ago

      • I’m very glad to hear that. Thank you for the response.

        8 months ago

  • Replies: 2

    Hi! Your tutorials are amazing. I’m getting a weird yellow error on the particle tutorial.

    Assets/Scripts/particlesScript.cs(23,41): warning CS0618: `UnityEngine.ParticleSystem.enableEmission’ is obsolete: `enableEmission property is deprecated. Use emission.enable instead.

    When I changed it to what it said, I received a different error in red.

    Assets/Scripts/particlesScript.cs(23,50): error CS1061: Type `UnityEngine.ParticleSystem.EmissionModule’ does not contain a definition for `enable’ and no extension method `enable’ of type `UnityEngine.ParticleSystem.EmissionModule’ could be found (are you missing a using directive or an assembly reference?)

    Any suggestions?

    12 months ago

    • Replies: 1

      Unity has changed the way you can access particle system modules in Unity 5.3. You can see the updated example here: https://docs.unity3d.com/ScriptReference/ParticleSystem-emission.html

      I’ll need to update this lesson to make it applicable to Unity 5.3.

      11 months ago

      • I’m still extremely new to coding, so I’ll keep my eye out for your updated version to truly grasp how to adjust it. lol

        11 months ago

    • Replies: 0

      Sure thing. The lesson has been recorded and is now going through the editing/scheduling process now.

      11 months ago