Search Unity

Press button to go into AIMING POSITION with an animation?? HELP!

Discussion in 'Scripting' started by Haseeb_BSAA, Oct 1, 2014.

  1. Haseeb_BSAA

    Haseeb_BSAA

    Joined:
    Aug 20, 2014
    Posts:
    316
    Hi guys , I am making a Third Person shooter game , most of people have posted FPS tutorials and in FPS games , you are already in the Aiming Position.
    I want to make my aiming system like Resident Evil , you are just holding a gun but you can't shoot until you are in aiming position.
    I want my character to go into aiming position by pressing a key and move the gun onto the enemy and shoot.
    So when I release the button , it goes back into normal position.
    If you can provide me a script of that function , that will be a great great help for me , thanks a lot! :)

    Here are a few pictures showing what I want :
    Normal position =

    Aim Position =


    Thanks a lot!
     
  2. Cpt Chuckles

    Cpt Chuckles

    Joined:
    Dec 31, 2012
    Posts:
    86
    something like this is too abstract for us to just write code for you, having no knowledge of the rest of your engine, so i will help by outlining a plan

    you could have two empty objects in the game that represent the two possible positions for the camera: one right up on the shoulder, and one further back.
    have a boolean value in the camera script that checks if the aim button is held down. if it is, your camera movement script follows the over-the-shoulder empty. otherwise, the camera movement script sets the camera on the further-back empty.

    in your player object you may want to handle the aiming-mode in a separate script from the rest of the player. in fact, you might even want two completely different scripts for handling the player between the separate modes. when you are in regular mode, your regular script would handle running around like normal, and check for when the aim button is pressed. when that happens, you disable your regular script, and enable the aiming script. the aiming script will take the input X and Y and use it to aim, maybe have slower walking speed, and change the player model's animation. it will also handle shooting, which won't exist in the regular script.

    it's hard to elaborate more without seeing the rest of your code, but i hope this gives you an idea of where to start. come back with issues you run into when coding, and good luck
     
    Haseeb_BSAA likes this.
  3. Haseeb_BSAA

    Haseeb_BSAA

    Joined:
    Aug 20, 2014
    Posts:
    316
    Thank you so much Cpt Chuckles , that was definitely a great help !
    To be honest , I just started learning coding a few days ago so I cannot make my own scripts yet , I can understand the functions but I'll do many mistakes when it comes to coding from scratch.
    I am not using any script that I made , I use ThirdPersonController and ThirdPersonCamera script to handle my character , that script is already included in the unity.
    If you could make that script for me , it will be the best thing if you don't mind :)
     
  4. romi-fauzi

    romi-fauzi

    Joined:
    Aug 16, 2013
    Posts:
    161
    I would not want to make a script just like that, and you won't learn anything like that, so I'd would suggest you to go to the tutorials section first, and start learning the basic of scripting, and then start making simpler games first, without any complex mechanism. And from there try a more challenging mechanism, on step at a time.
     
    Haseeb_BSAA likes this.
  5. Haseeb_BSAA

    Haseeb_BSAA

    Joined:
    Aug 20, 2014
    Posts:
    316
    Okay :( Anyways , thanks!