Search Unity

Block Based coding Unity 2d games

Discussion in '2D' started by chloeclays, Sep 28, 2022.

  1. chloeclays

    chloeclays

    Joined:
    Sep 28, 2022
    Posts:
    12
    does anyone know how to create a trigger for a game object to move? To be more precise, I wanna make a 2d game on Unity where the user can drag and drop arrow (left,right, up and down) on the field and the game object can move accordingly to the arrow in the field?? And they can also put the loop inside the field to make a repetitive moves. The example is in the picture. The UI of my game I really dont have much idea cuz i have 0 experience in unity and this is for my final year project. For reference, i wanna make games like Kidlocoding or Codemonkey. Thanks a lot!
     
  2. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,465
    Just YouTube search Grid based movement 2d Unity
    upload_2022-9-28_12-11-4.png
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    Adding to what Corny says above, do a few grid game tutorials, but BE SURE you do them properly or you will be simply wasting your time.

    Tutorials and example code are great, but keep this in mind to maximize your success and minimize your frustration:

    How to do tutorials properly, two (2) simple steps to success:

    Step 1. Follow the tutorial and do every single step of the tutorial 100% precisely the way it is shown. Even the slightest deviation (even a single character!) generally ends in disaster. That's how software engineering works. Every step must be taken, every single letter must be spelled, capitalized, punctuated and spaced (or not spaced) properly, literally NOTHING can be omitted or skipped.

    Fortunately this is the easiest part to get right: Be a robot. Don't make any mistakes.
    BE PERFECT IN EVERYTHING YOU DO HERE!!

    If you get any errors, learn how to read the error code and fix your error. Google is your friend here. Do NOT continue until you fix your error. Your error will probably be somewhere near the parenthesis numbers (line and character position) in the file. It is almost CERTAINLY your typo causing the error, so look again and fix it.

    Step 2. Go back and work through every part of the tutorial again, and this time explain it to your doggie. See how I am doing that in my avatar picture? If you have no dog, explain it to your house plant. If you are unable to explain any part of it, STOP. DO NOT PROCEED. Now go learn how that part works. Read the documentation on the functions involved. Go back to the tutorial and try to figure out WHY they did that. This is the part that takes a LOT of time when you are new. It might take days or weeks to work through a single 5-minute tutorial. Stick with it. You will learn.

    Step 2 is the part everybody seems to miss. Without Step 2 you are simply a code-typing monkey and outside of the specific tutorial you did, you will be completely lost. If you want to learn, you MUST do Step 2.

    Of course, all this presupposes no errors in the tutorial. For certain tutorial makers (like Unity, Brackeys, Imphenzia, Sebastian Lague) this is usually the case. For some other less-well-known content creators, this is less true. Read the comments on the video: did anyone have issues like you did? If there's an error, you will NEVER be the first guy to find it.

    Beyond that, Step 3, 4, 5 and 6 become easy because you already understand!

    Finally, when you have errors...

    Remember: NOBODY here memorizes error codes. That's not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

    The complete error message contains everything you need to know to fix the error yourself.

    The important parts of the error message are:

    - the description of the error itself (google this; you are NEVER the first one!)
    - the file it occurred in (critical!)
    - the line number and character position (the two numbers in parentheses)
    - also possibly useful is the stack trace (all the lines of text in the lower console window)

    Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

    All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don't have to stop your progress and fiddle around with the forum.
     
  4. chloeclays

    chloeclays

    Joined:
    Sep 28, 2022
    Posts:
    12
    i have no problem with grid movement cuz it can be set using vector. i just wanna know how to trigger the game object to move when the (left right up down) button is dropped into the command field. https://www.kidlocoding.com/ this is the example game i wanna create
     
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,497
    Nobody is going to tutor you or write scripts for you on how to use Unity. You're asking for things that are composed of learning a bunch of separate things i.e. input, physics, scripting etc. You need to learn those in tutorials or documentation.

    If you have specific 2D feature questions then go ahead and use this forum but for general scripting questions use the Scripting forum.
     
  6. chloeclays

    chloeclays

    Joined:
    Sep 28, 2022
    Posts:
    12
    maybe just give an idea
     
  7. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,497
    What does that mean? Just describe how to do what you want to do? In a few words? Isn't the idea to perhaps follow tutorials on the individual parts that are required to do what you want?

    Forums are for asking specific questions, not to ask how to write systems for games which are comprised of many things requiring you understand them.

    It's your task to make it super clear what you want and not the task of others answering to spend significant amounts of time trying to figure out what it is you want.
     
  8. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,497
    I just don't follow what you're asking here because you're using your own terminology. What's a command field? What does this sentence really mean? It's not like anyone here has experience on the products you're referring to. We're not going to download it and try to understand what you want. ;)

    For all I know you're asking how to put a button on the screen (UI) and know when it's been clicked. Or you might be asking how to move something. Or something else like drag/drop.

    Even if you are, the above are things you need to learn. UI tutorials for buttons etc.

    https://learn.unity.com/tutorial/creating-ui-buttons
    UI Forum: https://forum.unity.com/forums/ugui-textmesh-pro.60/
     
  9. chloeclays

    chloeclays

    Joined:
    Sep 28, 2022
    Posts:
    12
    Thank you so much for this! I appreciate it a lot
     
  10. chloeclays

    chloeclays

    Joined:
    Sep 28, 2022
    Posts:
    12
    For reference, I want to make games like https://www.kidlocoding.com/. exactly like that. I have followed few tutorials but i just cant connect them as a whole. Its a mainly drag and drop to make a game object to move.
     
  11. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,497
    I know, you've posted the link above several times.

    This is why I said you need to follow tutorials. Just typing in "Unity Drag and Drop" in Google gives dozens of tutorials like this:
     
  12. chloeclays

    chloeclays

    Joined:
    Sep 28, 2022
    Posts:
    12
    I have done this but ill give it a try again. thank you!
     
    MelvMay likes this.
  13. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    He did, you must have missed it. He said:

    Have you? Have you really? I suspect not because if you did it properly, you would not be asking a completely vague broad question.

    YOU MUST DO STEP #2 BELOW... NO EXCEPTIONS!

    Tutorials and example code are great, but keep this in mind to maximize your success and minimize your frustration:

    How to do tutorials properly, two (2) simple steps to success:

    Step 1. Follow the tutorial and do every single step of the tutorial 100% precisely the way it is shown. Even the slightest deviation (even a single character!) generally ends in disaster. That's how software engineering works. Every step must be taken, every single letter must be spelled, capitalized, punctuated and spaced (or not spaced) properly, literally NOTHING can be omitted or skipped.

    Fortunately this is the easiest part to get right: Be a robot. Don't make any mistakes.
    BE PERFECT IN EVERYTHING YOU DO HERE!!

    If you get any errors, learn how to read the error code and fix your error. Google is your friend here. Do NOT continue until you fix your error. Your error will probably be somewhere near the parenthesis numbers (line and character position) in the file. It is almost CERTAINLY your typo causing the error, so look again and fix it.

    Step 2. Go back and work through every part of the tutorial again, and this time explain it to your doggie. See how I am doing that in my avatar picture? If you have no dog, explain it to your house plant. If you are unable to explain any part of it, STOP. DO NOT PROCEED. Now go learn how that part works. Read the documentation on the functions involved. Go back to the tutorial and try to figure out WHY they did that. This is the part that takes a LOT of time when you are new. It might take days or weeks to work through a single 5-minute tutorial. Stick with it. You will learn.

    Step 2 is the part everybody seems to miss. Without Step 2 you are simply a code-typing monkey and outside of the specific tutorial you did, you will be completely lost. If you want to learn, you MUST do Step 2.


    Of course, all this presupposes no errors in the tutorial. For certain tutorial makers (like Unity, Brackeys, Imphenzia, Sebastian Lague) this is usually the case. For some other less-well-known content creators, this is less true. Read the comments on the video: did anyone have issues like you did? If there's an error, you will NEVER be the first guy to find it.

    Beyond that, Step 3, 4, 5 and 6 become easy because you already understand!