Unity Community


Page 1 of 2 12 LastLast
Results 1 to 20 of 28

  1. Location
    Switzerland
    Posts
    21

    Very simple game ideas to learn C#

    Hi guys,

    Months ago i almost finished 2 games with unity, the first game was Simon but i didn't finished it because i had a problem with Playmaker (it was a bug, not user error) so i forgot about the project and i never went back. (i was really close to make it work )

    The second game was Minesweeper and i went pretty far as well, i still used Playmaker but this time i left because i messed up the "code" (i used raycasting to open cells and of course that made the game lag really bad, imagine firing 100 or more rays in a second .-.) and i had other problems and i didn't come beck to fix them.

    (i still have 2 screenshots: Simon Minesweeper)

    BUT, anyway... i'm here because i think that i should learn how to program in C# without using Playmaker (which is really awesome BTW, i'm not saying that's bad!) and i wanted some ideas to start out. as you can see i give up easly and lose motivation quickly but i want to give it a try.

    so here's a list of simple games that came in to my mind, do you have some other ideas? which would you go for if this was your first game?

    snake
    tetris
    memory
    minesweeper
    bomberman (maybe without AI...)
    roll the ball
    cannon shooter (2D, you are a tank and you shoot paratroopers and elicopters that come from the sky)
    simon
    battleship
    space invaders
    pong

    i'll probably try minesweeper again, hopefully without messing up everything
    Forgive my english


  2. Location
    NYC
    Posts
    803
    Jumpman...namely Mario, one level, you jump and you stomp on something.


  3. Location
    Wisconsin, USA
    Posts
    2,639
    Pac-Man: Still has some AI, but its relatively simple.
    Burgertime: Even easier AI. Maybe just leave out the enemies for now.


  4. Location
    Gold Coast, Australia
    Posts
    3,593
    Your list is good. My advice however is to learn how to program C#, and how to program in Unity separately.


  5. Location
    Brasilia, Brasil
    Posts
    19
    Space Invaders. It'll teach you many things about how stuff works and interacts to create gameplay in Unity.


  6. Posts
    3,768
    Quote Originally Posted by npsf3000 View Post
    My advice however is to learn how to program C#, and how to program in Unity separately.
    This. Most people who jump straight to learning to program for games skip over a lot of fundamental stuff which is really important. The first step is to understand programming. Once you've done that, then apply what you've learned to making games.


  7. Location
    Amsterdam
    Posts
    426
    Originally Posted by npsf3000
    My advice however is to learn how to program C#, and how to program in Unity separately.
    This. Most people who jump straight to learning to program for games skip over a lot of fundamental stuff which is really important. The first step is to understand programming. Once you've done that, then apply what you've learned to making games.
    I don't necessarily agree here. I think you can learn programming by making games. Unity is a great way of learning the basic concepts of programming. Just learning the abstract concepts isn't a lot of fun. But when you're actually creating an object that you can move through user input you actually feel like your getting results which is a lot more motivating then say perhaps the learning how to use delegates or inheritence.

    These concepts will follow eventually but learning all these programming principles beforehand might be a too steep learning curve. Atleast for me I learned programming by just asking myself what the results were I wanted to accomplish and then figuring it out. It was only after I completed few games that i wanted to dive deeper into the skill and art of programming itself.

    What i do recommend is that you buy a C# book which goes over all programming concepts.

    When I started out with Unity the first thing I was making was a first person shooter because you already have the standard assets for that and then just add features like a gun shooting, a health bar, a turret that shoots back etc etc.

    just my 2 cents
    -design & develop through play-


  8. Location
    Gold Coast, Australia
    Posts
    3,593
    Quote Originally Posted by SimonAlkemade2 View Post
    I don't necessarily agree here. I think you can learn programming by making games.
    I didn't say you couldn't learn programming from making games -you can certainly learn a lot - however I think the resources aren't there to learn the fundamentals.

    By doing both - learning raw C# in console [or form] applications and then learning how to apply that in game dev I've seen some huge benefits IMO.


  9. Posts
    1,137
    If you have zero experience in programming then jumping straight into unity C# will be harder than a form application like npsf3k said. But it can also be confusing because unity works a bit different from classic C# applications in a sense that it uses components and gameobjects instead of doing a "new" on everything.

    I personally learned C# purely in unity but I already had some experience with other languages so that gave me a huge boost.
    C# Yellow book helped me a lot to get a hang of C#. It has nothing to do with unity, but all the concepts can easily be tested in unity so there was little difficulty. Though you also need to read up on how unity works so you know to put stuff into Start() and Update() instead of Main().

    What I would recommend is get a C# book and unity script reference and experiment away.
    It helps a lot if you have a friend in real life or on skype who knows C# and is willing to help. Though this is true when learning anything. If you're in Europe or a timezone near +2 I could help out a bit if you're interested. PM me if so.
    Last edited by Morning; 10-23-2012 at 04:56 AM.
    Please use [code][/code] tags when posting code. Otherwise rapid eye bleeding can occur.


  10. Location
    Switzerland
    Posts
    21
    Thanks guys for your replies,
    i did not mention that i already have a small knowledge in programming, in fact i learnt C++ at school during the first year. for now i know how to use loops, if-else, variables, arrays...but not much more. I think that i'll start with minesweeper again since i already know how it works (more or less) and then go with something like space invaders.

    if you have any other suggestions or ideas for games please let me know ^^ i really apreciate your help.
    Forgive my english


  11. Location
    São Paulo, Brazil
    Posts
    55
    One simple game suggestion is Hanoi Towers.

    My simple projects (I won't call them games 'cos they're incomplete) were:

    -A First person explorer/item collector;

    -A sidescroller arcade mix between penguin launcher and Jetpack joyride;

    -A simple one level pinball; (I really want to build a nice pinball game)

    -Some gravitational physics simulation experiment.

    But as said on this thread, I had programming experience before get to unity, so it helped a lot to see how programming in Unity is different from standard console/form programming, and mainly where I could go with unity. To think outside of unity's box (which is quite big!)

    But all that is my experience and POV, so I don't take it as the universal truth.

    That being said, my advice for people that want to learn strictly game programming woud be:

    -Get a big book about the language you want to learn. And it should be Object Oriented paradigm. (My advice here works for C#)
    -Follow book instructions to get the basics. From "Hello nurse!" (I mean world) to something like loops and some basic data structure like array or list.
    -Implement simple console programs as calculator, cash ATM, etc...

    At that point you can get a little unmotivated. But stand tight, things will get a little better. I think this knowledge recently developed would give you the basics to start experimenting game related lessons. For that:

    -Find your way installing Microsoft's XNA game platform. (C#)
    -Learn how XNA's Update and Draw methods works.
    -With the previous knowledge acquired you should start practicing the Object Orientation part of the story. Creating Classes and getting to know inheritance and polymorphism. This is really valuable to see what unity already brings up to you and what you can do with it.
    -Try to implement simple games with XNA. The simplest games already gives you some perspective of what I'm talking about.

    And then you should bring that big backpack of fresh knowledge to unity and (try to) have fun!

    I mostly did that. But I started with java at university. But Java or C# won't matter. The concepts behind them will.

    And good luck!


  12. Location
    Virginia, USA
    Posts
    1,374
    @OP - You have the right approach. Don't stop to learn all of C#, just pick small things (yer list is fine). Then, learn what you need to learn, as you need it, and focus on completing stuff!

    Instead of dropping projects, drop features or pick smaller projects. Set a date 8 weeks away and built something. My wife goaded me: 'even if it's just your name bouncing up and down'. Completing a project gave me a HUGE boost to my morale. Completing MULTIPLE projects ... well... you'll see.

    Inspirational quote from Joel Spolsky: "Shipping is a feature. A really important feature. Your product must have it."

    Gigi
    What Went Well - a Meditation on Gratitude and Happiness
    Good Sex, Great Marriage - Still The #1 Marriage App on iOS *** Also on Android!
    The Gratitude Habit - 1000 5-star reviews

    The Secret of Success? Try; Improve; Repeat- 'till too good to ignore.


  13. Location
    Italy / UK
    Posts
    347
    Get the free C# games package in the Asset Store and mess with them (modding, mixing, playing with scripts)
    digital edutainment venture: www.NuclearResearch.net --- First themed mobile game coming in May (made with Unity!)

    ebook: 10 critical problems in nuclear engineering 2014 for Kindle and PCs

    Rubbish FREE breakout clone: Rush Breaker for Android or Rush Breaker for iOS (if your market supports iAds)


  14. Location
    Switzerland
    Posts
    21
    thanks again for all your help, i already started making a simple script that will allow the spaceship to move and shoot (i'm going for space invaders).
    for now the ship can move left/right and can already spawn the bullets.
    however for now they don't move. i have to find a way to make them move forward without using rigidbodies and AddForce.

    Code:  
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Spaceship : MonoBehaviour {
    5.     public int speed = 25;
    6.     public Transform bullet;
    7.  
    8.     public void Update () {
    9.         float translation = Input.GetAxis("Horizontal")*speed*Time.deltaTime;
    10.         this.transform.Translate(translation,0,0);
    11.         if(Input.GetKeyDown(KeyCode.W)){
    12.             Transform bulletPrefab = Instantiate(bullet,this.transform.position,Quaternion.identity) as Transform;
    13.         }
    14.     }
    15. }
    Forgive my english


  15. Location
    NYC
    Posts
    803
    You should make a script on the spawned bullet to propel it's self forward. It's a little different kind of thinking than in RL. Think of the bullet like a missile. Missiles propel themselves to the target.


  16. Location
    São Paulo, Brazil
    Posts
    55
    To proper set up the collision of the bullet, one of the two objects involved in the collision (bullet or target) must have a rigidbody (uncheck gravity; check kinematic), and make sure you check the collider of the bullet as trigger.

    This is a simple C# script for a simple bullet.

    You can apply this script to your prefab bullet and tweak the values from the editor.

    Code:  
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class LaserController : MonoBehaviour {
    5.    
    6.     public float damage;
    7.     public float speed;
    8.     public float lifeSpan;
    9.     private float timer = 0.0f;
    10.  
    11.     // Use this for initialization
    12.     void Start () {
    13.    
    14.     }
    15.    
    16.     // Update is called once per frame
    17.     void Update () {
    18.        
    19.         if (timer < lifeSpan)
    20.         {
    21.             transform.Translate(Vector3.forward * speed * Time.deltaTime, Space.Self);
    22.         }
    23.         else
    24.         {
    25.             Destroy(gameObject);
    26.         }
    27.        
    28.         timer += Time.deltaTime;
    29.    
    30.     }
    31. }

    Maybe someone can improve it.
    Last edited by GeorgeRigato; 10-23-2012 at 01:11 PM. Reason: adding information about setting up a collision properly


  17. Location
    NYC
    Posts
    803
    Line 25
    Code:  
    1. Destroy(gameObject, lifeSpan);

    It can destroy itself with the allotted time.


  18. Location
    Switzerland
    Posts
    21
    Thanks i tried it and it works like a charm

    Quote Originally Posted by Kinos141 View Post
    Line 25
    Code:  
    1. Destroy(gameObject, lifeSpan);

    It can destroy itself with the allotted time.
    the George's script works already (enters the else only when time is >= lifeSpan)
    Forgive my english


  19. Location
    NYC
    Posts
    803
    I agree it does the same thing, but this is cleaner code.

    you'd write less lines with this.

    Code:  
    1. void Update()
    2. {
    3.       transform.Translate(Vector3.forward * speed * Time.deltaTime, Space.Self);
    4.       Destroy(gameObject, lifeSpan);
    5. }

    Done.


  20. Location
    Switzerland
    Posts
    21
    Quote Originally Posted by Kinos141 View Post
    I agree it does the same thing, but this is cleaner code.

    you'd write less lines with this.

    Code:  
    1. void Update()
    2. {
    3.       transform.Translate(Vector3.forward * speed * Time.deltaTime, Space.Self);
    4.       Destroy(gameObject, lifeSpan);
    5. }

    Done.
    ah ok, now it's clear! thanks

    EDIT: i added the possibility to keep space down and let the spaceship shoot every x seconds, however you can shoot faster if you press-and-release the spacebar by yourself.
    the code works for now but i'm sure it needs improvements.
    Code:  
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Spaceship : MonoBehaviour {
    5.     public int speed = 25;
    6.     public Transform bullet;
    7.     public bool canShoot = true;
    8.     float reload = 0;
    9.     public float timeBtwnShots = 0.1f;
    10.     // Use this for initialization
    11.     void Start () {
    12.    
    13.     }
    14.     // Update is called once per frame
    15.     public void Update () {
    16.         float translation = Input.GetAxis("Horizontal")*speed*Time.deltaTime;
    17.         transform.Translate(translation,0,0);
    18.         if(Input.GetKeyDown(KeyCode.Space)){
    19.             Transform bulletPrefab = Instantiate(bullet,this.transform.position,Quaternion.identity) as Transform;
    20.         }
    21.         if(Input.GetKey(KeyCode.Space) && canShoot == true){
    22.             Transform bulletPrefab = Instantiate(bullet,this.transform.position,Quaternion.identity) as Transform;
    23.             canShoot = false;
    24.             reload = 0;
    25.         }
    26.         reload = reload + timeBtwnShots; //the name "TimeBtwnShots" is not correct, higher values mean faster shooting. i'll fix this when i'm less tired
    27.         if(reload >= 10){
    28.             canShoot = true;
    29.         }
    30.     }
    31. }

    for now i'm very happy with this project, i hope to keep it alive. a BIG THANKS to this amazing community, you're very helpful and kind!
    Last edited by pustur; 10-23-2012 at 03:04 PM.
    Forgive my english

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •