Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

"Create your own 2D game without coding!" I have years of experience in coding, where do I start?

Discussion in 'Getting Started' started by freelancemolnarandrei, Jul 15, 2018.

  1. freelancemolnarandrei

    freelancemolnarandrei

    Joined:
    Jul 15, 2018
    Posts:
    1
    The first tutorials that I've looked through use components for verything.

    I come from gamemaker studio, and I have plenty of experience in Java, Python, SQL databases etc.
    In gamemaker, I can create an object, and ignore their "drag and drop" for the sake of my own code.
    Through this code I can just check if a key is pressed, and then change the object's position.
    How would I be able to do this with scripting alone?

    This may be a misjudgement... but is Unity made primarily for working with components, and second for scripting/coding?

    Is there anything better than the reference scripting API ?
    I mean if I search "movement", I need to wait for 5 seconds, or more, and then I just don't find what I need...
     
  2. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,466
    Component are just scripts, but go to learn section and then script to know about the quirk of unity.

    Basically:
    - you write component script that derive from the monobehavior class,
    - then use the various flow control like start() and update() to make the behavior,
    - those behavior attach a game object, you need at least one game object in a scene,
    - the script can access to all component attached to that gameobject.

    Unity is not drag and drop for logic at all, if you want to move a character you need to change its position through code.

    Please go to the learn section first, and read the manual thouroughly:
    https://unity3d.com/fr/learn
    https://unity3d.com/fr/learn/tutorials
    https://docs.unity3d.com/Manual/ind...34.1099690227.1531107416-180455106.1521421014
    https://unity3d.com/fr/learn/tutorials/topics/interface-essentials
    https://unity3d.com/fr/learn/tutorials/s/scripting
     
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Unity uses the composite design pattern heavily. Each GameObject is basically just a container that holds a bunch of components. The components are where all of the magic happens.

    There are a huge number of build in components. These are primarily for accessing Unity's build in systems. Want to access the physics library, then use the Rigidbody and Collider components. Want to access the UI system, then use the Canvas and Button components. Redering uses Mesh and Renderer components. And so on.

    But don't let the vast number of built in components fool you. Unity doesn't write your game for you. Most of your coding time will be spent writing your own components. These can get as complicated as you like. You have the full power of .NET and C# at your finger tips.

    Create this component and add it to an empty GameObject.

    Code (CSharp):
    1. public class MoveOnKey : MonoBehaviour {
    2.  
    3.     [SerialiseFeild]
    4.     int speed = 5;
    5.  
    6.     void Update () {
    7.         if(Input.GetKey(KeyCode.Space)){
    8.             transform.potion += Vector3.up * speed * Time.deltaTime;
    9.         }
    10.     }
    11. }
    It only gets more complex from here. Unity lets you code as much as you like. And components are how you use that code in a practical fashion.
     
    Ryiah and Schneider21 like this.