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

Applying a cross hair to 3D environment (think Cannon Fodder)

Discussion in 'Game Design' started by OneMoreRound, Apr 12, 2018.

  1. OneMoreRound

    OneMoreRound

    Joined:
    Jul 22, 2015
    Posts:
    46
    Hello,

    I have a 3D game environment that looks similar to Cannon Fodder


    I want to recreate the technique where when a button is held down (PS4_L2 in my instance) a cross-hair appears on screen that is controlled with Right Analogue Stick. The Left Analogue Stick currently controls my Player. My cross-hair is currently a png file. Firing will likely be done by raycasting from my players.

    This game will allow for multiple players, so that needs to be considered also. (multiple crosshairs)

    I'm new to Unity and can't find a tutorial that replicate similar to what I want to do.

    What is the best approach I should take to do this?

    Thanks
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,840
    This sounds like more of a getting-started question than a game design question, since it seems you've already decided on the game design.

    To implement it, just write a script that reads the horizontal and vertical axes of your right analog stick (which you'd set up in the Input Manager), and moves the crosshair accordingly.
     
    angrypenguin likes this.
  3. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,504
    Yep, and once you've got that working on a flat terrain you could consider a few ways to make it handle depth/height. One way would be to cast a ray down from above to find the appropriate height for the reticle, with rules for how far up/down you can aim. Another way would be to use a projector and ignore the height of the point being aimed at.
     
    OneMoreRound likes this.
  4. OneMoreRound

    OneMoreRound

    Joined:
    Jul 22, 2015
    Posts:
    46
    This sounds really interesting. I've just copied the 'health circle' idea from the Tanks Tutorial, and when I go over raised terrain, the health slider disappears - your method sounds like it would fix this.