Search Unity

Drag'nDrop 3D edu Game

Discussion in 'Getting Started' started by Deleted User, Apr 21, 2017.

  1. Deleted User

    Deleted User

    Guest

    Hello there,

    I am a newbie to Unity and I would like to build a game in Unity 3D as a school educational project. My concept is a "Computer Building Game".

    The first view is main view to entire computer table. Then, I've got a menu in front of view. There are only 3 buttons. Then, there should be 3 views- main, side view to case and components and back view to case. When user clicks the case, it will move the camera to the right position and user is able to drag and drop components to the case. After that, user clicks any button and the camera view moves to the back of case and user is able to connect cables from peripherals. Then, again, click the button and user is able to see whole scene and after hover over "Power on" button, the camera zooms it and user can click it and run computer. Than there should be a message on the screen, whether is everything allright or not.

    I've searched a lot but none of the scripts is working as I want. So there are my questions and I'd be glad for any advise.

    1. Firstly, I want to make game paused (everything- rigidbodies, my scripts) until the user clicks the start button. I've read, there is some function to do this but I don't know where to put it.
    2. Secondly, I want to make camera move closer to the case and shelf with components after clicking to the case. I've read about animator but I don't know how to do that. So any camera movement script after click?
    3. Any script to drag and drop components and snap to exact place in the case? If not in the right place, move back to start position.
    4. The same with cables- snapping to right places.
    5. Controller if components are all in right place- if some is missing, write message to a screen. I know, I should place it to an array after snapping to a right place and then loop in the array and check it.

    Now I've got only two scripts to drag and drop objects which is not working as I want to (I want to move objects to all axis.) and to snap objects which is not done.

    Can you help me with the scripts? Thank you a lot :)
     

    Attached Files:

  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Wow, this is a pretty ambitious project for a complete beginner. Especially if you don't have much programming experience.

    I don't have time to write your scripts for you, but here is some general advice relative to your points above that I hope is helpful.

    1. This game shouldn't have any rigidbodies in it. Certainly not any non-kinetic ones. You don't need things moving around under control of the physics engine; from your description, it's clear that anything moving will be doing so from scripts (or animations). So if you have any rigidbodies, delete them. And then question 1 goes away; you don't need your game paused at all.
    2. Animator is actually a pretty decent way to move the camera in this case, I think. If you don't know how to do that then you need to read about it again, or watch some tutorials.
    3. Dragging and dropping in 3D is tricky; you'll have to think very carefully about what you mean by that. The mouse can only indicate a 2D position; how will you infer the third dimension? Once you've worked that out on paper, writing the code should be pretty straightforward. To snap, just calculate the distance between where the user drops the part, and the correct position for that part. If it's close enough, assign the correct position; otherwise, return it to the start position.
    4. Same as 3.
    5. Sounds to me like you've got the right idea here. Clearly you're going to need some sort of manager script that knows about all the parts, so it can do this check to see when they are all in place.

    There are no shortcuts here — to do this project, you'll need to work through the tutorials and build up your skills. But if you work hard and have enough time, I'm sure you can do it!
     
    Kiwasi and Schneider21 like this.
  3. Deleted User

    Deleted User

    Guest

    Thank you a lot. I'm glad for even smallest advices. However, I'm not a complete beginner. I already did some projects in Java, I understand Javascript and C#. What I only need is to know how to do these things in Unity and the basic principles. I'd be glad for some pieces of code and explanation from anyone :)
     
  4. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    If you're already familiar with programming in general, it may be useful reading through the API reference, as well as the Manual. I can only speak for myself, of course, but while I'm happy to help debug people's scripts and hunt down logic or syntax errors for them, I'm very reluctant to design and create from scratch big code blocks that meet feature requirements people have in mind. Most of us have full-time jobs, families, social lives, and our own projects that keep us occupied, and spending a great deal of unpaid time creating work for other people is a tough sell.

    I encourage you to think like a programmer. Break the tasks down into their smallest parts and approach them one by one. If you know you want to be able to pick a PCB board up from a shelf and move it around, get that implemented first. If you don't know how to do it, read through the manual and API and use Google to find out more. There's a really good chance that anything you can think to ask at this point has already been asked many times before, and the answers are already out there.

    When you do run into a situation that nobody in the world has ever asked before ("I want to only be able to pick a PCB from the shelf if the current in-game day is Tuesday and the real-world day is Friday, and the player is using a Galaxy S6 phone"), create a post describing your issue in detail, share the code you've written using code tags, describe what behavior you're expecting versus what you're getting, list verbatim any console errors you're receiving, and you'll find plenty of people more than happy to jump in and help!

    Good luck!
     
    Kiwasi and JoeStrout like this.
  5. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    For drag and drop with snapping and resetting you can adapt this.