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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How to create items from within a vehicle in real-time in Unity?

Discussion in 'Editor & General Support' started by jnt_27, Jun 21, 2020.

  1. jnt_27

    jnt_27

    Joined:
    Jun 18, 2020
    Posts:
    5
    Hello,

    I am making an FPS game. I want to be able to get into vehicles and then construct items from within the vehicle on demand and in-game. Picture a pilot that gets into a tank and then while inside the tank he can create walls, ammo/repair packs, weapons etc in the heat of battle.

    However, I have no idea what scritps/etc I should use for this. Can someone point me in the right direction?
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,120
    You're kind of asking how to build a whole game here... What have you tried? You're talking about several different mechanics. Maybe start prototyping a building system, or prototyping a vehicle system? I mean, you could look on the asset store if you're trying to find just some stuff someone else made, but if you're looking to improve your skills you should start somewhere and ask for help on the specifics.
     
    PraetorBlue likes this.
  3. jnt_27

    jnt_27

    Joined:
    Jun 18, 2020
    Posts:
    5
    Hello, thanks for the response.

    Yes, I'm brand new to unity and C# in general (4 days). I just want to see what it is I need to do, which you've been helpful with.

    I suppose I'm thinking specifically about some sort of HUD based building mechanic like in Battlezone 98, but I'm afraid I can't give you any more details as I know next to nothing about how I would achieve it.

    See below image for what I'm talking about, except a building can be built through the targeting reticle.
     

    Attached Files:

    • bz.png
      bz.png
      File size:
      426.4 KB
      Views:
      274
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,120
    Well, the kind of game you're describing definitely isn't one I'd recommend to someone as a first project in Unity. But you can always take things one step at a time, learning as you go, and eventually figure out how to combine them.

    Maybe you could start by building a mechanic where you just draw something on the ground, the way game let you "preview" where an object will go. I'd look into using Physics.Raycast to get the point in the world directly ahead of your mouse. Then, as long as it's close enough (distance from camera to that point less than a certain amount) and the ground is flat enough (normal of the raycast hit is very close to Vector3.up), put an object at that position, and move it as the mouse moves so it's always at the hit point.

    Even that little bit has a fair bit of complexity. So, just be aware that what you're trying to do isn't all that simple in general, nevermind as a first project. But, chip away at it, I guess.
     
  5. jnt_27

    jnt_27

    Joined:
    Jun 18, 2020
    Posts:
    5
    Thank-you, that's a lot of help.