Search Unity

Question Which method should I use for building system?

Discussion in 'Scripting' started by Unitkiv, Jan 4, 2024.

  1. Unitkiv

    Unitkiv

    Joined:
    Jun 14, 2022
    Posts:
    71
    I would use image slider for the building process. Are there any other method for to use in building process. If there has ready-made slides for Unity, where can I find ready-made slides for this kind of project.
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,527
    What?

    A "building process" - what is a "building process"? Describe the actual thing you're creating since this name is pretty abstract/ambiguous.

    A "image slider" - like a scrollbar? How does this relate to a "building process"?

    I've created games where you can place furniture into a scene that has a scrollbar region at the bottom of the screen that you drag things out of. But this was more like a decorating thing I created and the scrollbar was the least of the complexities of it (the complex thing was the drag/drop and making sure it didn't overlap with stuff). Think something like Sims.

    But like say in Valheim you can "build" your own houses and what not. And there is nothing in that process I would consider a "image slider".
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,676
    Do you just mean a progress bar?

    A
    UnityEngine.UI.Image
    configured to be "Filled" type can do this.

    Or just google for progress bars. There's a bazillion tutorials.
     
  4. Unitkiv

    Unitkiv

    Joined:
    Jun 14, 2022
    Posts:
    71
    I mean when a building is selected from the menu, and when I put this building some place in the game world the building process will start to the end within the certain amount of time. Yes, it will have a progress bar but how can I prepare/manage the images? Through the image frames (frame by frame) asset or through a slideshow asset (if Unity has this kid of assets)?
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,676
    Go look at filled UnityEngine.UI.Image components, as I listed above.

    Or again, go look at tutorials. I am NOT retyping a tutorial here for you.
     
    Unitkiv likes this.
  6. ReoCyan

    ReoCyan

    Joined:
    Sep 25, 2023
    Posts:
    35
    He may mean images as in the images for the sprites in the game. Hey Unitkiv, can you show me your game in a screenshot and tell me what you mean. Is it a canvas or not?
     
  7. ReoCyan

    ReoCyan

    Joined:
    Sep 25, 2023
    Posts:
    35
    Is it IN a canvas
     
  8. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,527
    OP needs to properly describe their situation instead of us trying to guess what it is they're talking about.

    My signature used to have a phrase in it, I deleted it a while ago though. It was somewhere in the vicinity of:
    "Programming is the act of telling a computer what you want. If you can't describe it to us as humans... what makes you think you can describe it to your computer?"

    OP... maybe some pics of what you're trying to do?
     
    Kurt-Dekker likes this.
  9. Unitkiv

    Unitkiv

    Joined:
    Jun 14, 2022
    Posts:
    71
    I am asking building process system like in this video (3:54), video (37:54).
     
    Last edited: Jan 5, 2024
  10. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,527
    Are you intentionally being vague?
     
  11. Unitkiv

    Unitkiv

    Joined:
    Jun 14, 2022
    Posts:
    71
    I'm watching Code Monkey's Simple Building System in Unity tutorial. In the tutorial I've stuck in part 02:26 as I get error when I attempt to place the prefab (I modified the code. Is there has any other way to execute this code without grabbing the Utilities from unitycodemonkey.com?)
    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class BuildingManager : MonoBehaviour
    7. {
    8.     [SerializeField] private Transform PfWoodHouse;
    9.  
    10.  
    11.     private InputManager inputManager;
    12.  
    13.     private void Update()
    14.     {
    15.         if (Input.GetMouseButtonDown(0))
    16.         {
    17.             Vector3 mousePosition = inputManager.GetMouseWorldPosition();
    18.             Instantiate(PfWoodHouse, mousePosition, Quaternion.identity);
    19.         }
    20.     }
    21. }
     
  12. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,827
    Need to know what the error is.
     
  13. Unitkiv

    Unitkiv

    Joined:
    Jun 14, 2022
    Posts:
    71
    When I press the left mouse button it brings me the "Object reference not set to an instance of an object" error message. I already put the prefab in the field of the BuildingManager component.
     
  14. Nad_B

    Nad_B

    Joined:
    Aug 1, 2021
    Posts:
    720
    input manager is null (not instantiated). Check again the tutorial and see how he's instantiating the input manager (maybe just a
    private inputManager = new InputManager();
    )
     
  15. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,676
    No matter how many times you see this error...

    The answer is always the same... ALWAYS!

    How to fix a NullReferenceException error

    https://forum.unity.com/threads/how-to-fix-a-nullreferenceexception-error.1230297/

    Three steps to success:
    - Identify what is null <-- any other action taken before this step is WASTED TIME
    - Identify why it is null
    - Fix that