Search Unity

noob to pro in one week

Discussion in 'Works In Progress - Archive' started by iamthwee, Dec 5, 2015.

Thread Status:
Not open for further replies.
  1. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,155
    I'm not sure what that means, are you saying I need to parent my light object to a game empty. SetActive doesn't work on a light source? Well when I tried it, it came up with a compiler error. Is that best practice. Would it be easier to loop through tagged gameobjects, instead of lights?

    @passerbycmc I'm afraid I have to kept my trap shut as if I share my opinions on c# or java only profanities will come out! lol. But granted I suppose it is easier to learn than c++. Still, if it were up to me 'google golang' would be my choice, compiled language with an expressive syntax and no OOP.

    Is this blox2 thing that gamegirl mentioned any good, or should I just stick to handwriting my scripts for now.

    I'm ready to hit the sack now, I'm exhausted!
     
    Last edited: Dec 12, 2015
  2. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    657
    Man sorry for this, i'm really tired right now and not really thinking straight.
    No you don't need to parent the light to a gameobject as it basically is already i think.
    light.enabled should work i think. Perhaps try mylight.gameobject.SetActive(false) but that will disable the whole thing, not just the light emission from the light. What wasn't working in the first light script you posted? what was the error?
     
  3. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,155
    There was no error, it was working, I was askng if it was best practice, but don't worry everyone has been a great help... I then got thinking how would I flicker all my lights in my scene, so I thought about adding a tag to them all.

    But I can't loop through all my lights in the scene, or I don't know how to, that's why I thought you were saying perhaps you should parent it to a gameobject? Honestly, I don't know my brain is frazzled trying to learn c# from the beginnng inside a week along with the unity UI, and all the snippets being in unity 4, not fun when I was expecting to just copy and paste, now I have to debug or try and frig the source from unity documents.
     
    Last edited: Dec 12, 2015
  4. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    657
    Oh! I though the original script wasn't working.
    If you place the lights under one gameobject, then you could be flicking them all from the parent.
    You'd need to modify the script into taking an array of lights, and in the update loop go through the array and flicker them.

    1. Code (CSharp):
      1. using UnityEngine;
      2. using System.Collections;
      3.  
      4. public class LightController : MonoBehaviour {
      5.    public Light[] myLight;
      6.    int arrayLenght;
      7.    // Use this for initialization
      8.    void Start ()
      9.    {
      10.        arrayLenght=myLight.Length;
      11.    }
      12.  
      13.    // Update is called once per frame
      14.    void Update ()
      15.    {
      16.        for(int i=0;i<arrayLength;i++){
      17.           if ( Random.value > 0.9 ) //a random chance
      18.           {
      19.               if ( myLight[i].enabled == true ) //if the light is on...
      20.               {
      21.                    myLight[i].enabled = false; //turn it off
      22.               }
      23.               else
      24.               {
      25.                    myLight[i].enabled = true; //turn it on
      26.               }
      27.           }
      28.       }
      29.    }
      30. }
      I haven't tested this yet, but you should place this in the parent object that has the lights as children. Then place all the lights in the array list in the editor.
      The arrayLength integer simply takes the length of the array to use it later on in the for loop.
     
  5. PenguinEmporium

    PenguinEmporium

    Joined:
    May 30, 2013
    Posts:
    134

    I feel your pain. It took a while for me to figure out how unity processes C#. As long as you have a general idea of how to do something, the online documentation is pretty useful.
     
    iamthwee likes this.
  6. Haseeb_BSAA

    Haseeb_BSAA

    Joined:
    Aug 20, 2014
    Posts:
    306
    Whenever I import a Unity 4 project with old API , Unity asks whether it should convert the code into new API or not. I click "Yes" and all my code from Unity 4's API is converted into new API. Not sure how can you do that manually but for importing projects , it works.
    Also , now I'm used to the new API , C# is love , C# is life.
     
  7. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,155
    Day 7/8

    Okay boys, after waking up with a headache and facing the dreaded c# language again I was ready to top myself lol. But held on in there and slogged through 3 hours of testing. Not fun at all and deceptively a lot of work, like a S*** load. My enemy just runs towards the wall then stops. I couldn't think of a way to get him to go back and forth. The cube has an empty parented to it which fire a prefab bullet on left mouse click.

    What I learned
    You need to have a strong stomach to stomach c# and it takes a ridiculous amount of time to do something simple. Nuff said. What I didn't have enough time was to add a point system, and a restart screen, I also wanted to code a simple floating 2D water engine but didn't get round to it. Also, I think it is good to restrict yourself to simple objects with no texturing, just so you can get the mechanics working, if you're a noob like me.

    plat.gif
     
    Last edited: Dec 13, 2015
  8. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,155
    Added some point lights that come on and off and changed the camera angle.

    plat2.gif
     
  9. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Which simple things take a ridiculous amount of time? It could be that there are easier ways to achieve that, or maybe you don't understand certain concepts yet.
     
    iamthwee likes this.
  10. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,155
    Just the language in general, it's too verbose, I don't doubt that once you have saved your snippets for movement etc, you can speed up the workflow, once I'm experienced I plan to ditch mono develop and set up sublime text 2, but for a pure noob, it's not happening. I just feel dirty using something microsoft created as I'm sure anyone would lol.
     
  11. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    It seems to be more complicated than you originally expected and now you need to vent a little. It would make sense not to start ideological discussions, because they will only prevent you from making progress.
     
  12. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,155
    No not at all, just the c# language is so poorly implemented IMO. Take a look at this ;)

    http://forum.unity3d.com/threads/quaternion-snapping-back-to-original-rotation.373548/

    Give me golang any day, compiled and expressively typed and nothing like java or c# or any of the other dotnet families, which have no place in today's modern programming world just terrible. But yes you're right, my thread isn't the place to start a language discussion :D

    Thanks
     
  13. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    This has nothing to do with C# or Microsoft. It is the API that is being defined by Unity in combination with someone who used it in an extremely unreadable fashion.
     
  14. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,155
    OK, but as I said before let's not talk about what language would be better or not, clearly unity have made they're bed with c#, I don't agree with it, but hey I guess they're trying to appeal to the dotnet boys. Nothing wrong with that, it's their business model -just not my cup of tea, I won't be using c# for anything other than inside unity - thankfully their mono runtime isn't constantly running otherwise I would have been long gone lol. ;)
     
    Last edited: Dec 13, 2015
  15. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,155
    Pain doesn't adequately describe what I am feeling right now! Use a much stronger word!
     
  16. screenname_taken

    screenname_taken

    Joined:
    Apr 8, 2013
    Posts:
    657
    Trust me on this one as i've been in your place before. Stop using youtube so much and get an actual printed book. Not an ebook. It may sound old fashion, but i started with youtube and unity's tutorials and i wasn't really getting much done. I was just having 3d shapes animated, but no idea on how to control actual gameplay. Then i went over in amazon and just got a book about unity and game making.
    I also tried ebooks, but simply because i can't actually put post it notes on the screen or that i couldn't actually hold the tablet while doing what i needed to be doing, i ended up getting a physical, well written book. By the time i was half way through it, i could figure stuff out by myself. The book was unityscript oriented instead of C# so i stuck with it.
    Now UnityScript may be going the way of Boo, so i was forced to learch C# for my next stuff which i didn't like to be honest. So i went ahead and ordered another book. But guess what, it hasn't arrived yet and i'm writting scripts in C# in a similar speed of when i was in UScipt.
    Currently i'm actually being paid to make something in Unity and i just started in C#.
    I'm also not sure that you can change Mono, i mean Unity's own runtime is based on Mono2.x as far as i know so wouldn't you need to change that?
     
    iamthwee likes this.
  17. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    You may just ask here if you have a question or create a new thread for that instead of derailing the thread.
     
  18. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,155
    This is where I think unity have made their biggest mistake. But I guess they wanted to hit a popular language that most people were familiar with. And I get why they didn't opt for python or any scripting language as it is too slow and c++ has too many ways to shoot yourself in the foot. Where they missed a trick was with golang, an expressively typed compiled language with a minimal garbage collector and routines, that are like lightweight threads.

    OK I admit not many people will be familiar with this, and yes there is going to be some level of verbosity when you're using an API, but compiled and expressively typed and cross platform. I know I'm going to have to stick with c#, don't get me wrong, I'm reading the online documentation now. Still I don't like it, it's just an opinion, whether I spend a week or a month it is unlikely to change. :D

    Sure ;)
     
  19. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    28,184
Thread Status:
Not open for further replies.
unityunity