Search Unity

Newbie Needs Help

Discussion in 'Editor & General Support' started by brian_s, Feb 2, 2012.

  1. brian_s

    brian_s

    Joined:
    Feb 2, 2012
    Posts:
    50
    So I'm new to this and am trying to make a first person shooter. I have gun and bullet imported from Cinema 4d into Unity using .fbx . I've bee trying to find a way to add scripts to the gun and bullet though, and I'm wondering what kind of scripts would be necessary.

    If this is not enough info, please tell me.

    Thanks in advance.
     
  2. MADmarine

    MADmarine

    Joined:
    Aug 31, 2010
    Posts:
    627
    Well for starters you probably want to make the gun a child of the main camera (just drag the game object onto the camera in the hierarchy view). This will ensure that wherever the viewport/player goes, the gun will go too.

    Usually in games, bullet models aren't really necessary, they move and hit the target so fast it's not even worth showing them (unless you're planning on doing some super slo mo gameplay). My advice would be to create a script that performs a Physics.Raycast() whenever the user presses down the left mouse button, with the result of that raycast you can see what was hit (if anything) and then decide what action to take.
     
  3. brian_s

    brian_s

    Joined:
    Feb 2, 2012
    Posts:
    50
    I've made the gun a child of the fpc. I still can't figure out how to script it though. When ever i go to the scripts menu at the top of my screen, the scripts are unselectable. Have I done something wrong?


    If this is not enough info, please tell me.
     
  4. ChaosWWW

    ChaosWWW

    Joined:
    Nov 25, 2009
    Posts:
    470
    The scripts menu on the top should be selectable if you have whatever object you want the script attached to selected. Personally, I prefer simply dragging the script from the project view onto whatever object I want the script to be attached to.
     
  5. brian_s

    brian_s

    Joined:
    Feb 2, 2012
    Posts:
    50
    i've tried what you've suggested but neither are allowing me to actually access Unitron to edit/add scripting.
     
  6. MADmarine

    MADmarine

    Joined:
    Aug 31, 2010
    Posts:
    627
    If you want to edit the script, double click (or right click > open) on the script in the 'Project' tab. Unitron should then open, displaying the code.

    If you want to assign the script to the object, make sure you find and click the object in the 'Hierarchy' tab. Once the object is selected, try going to the 'Component' menu at the top of the editor, then going to 'Scripts' and selecting the script you want to attach.