Scripts: github.com/Noblob/Aiming.git This shows you how to aim down sights when right click is being held in unity 3d Music: Fresh Start - Joakim Karud
Thank You So Much! I'm Currently Making A Multiplayer FPS Shooter Game In Unity Every And Every Other Tutorial Didn't Work I Thought This One Didn't Work Too, But Then I Realized My Animation For Aiming Down Sights Was Called ADS Not Aim And I'm Very Glad It Works!
honestly this channel is a dream come true for me if had difficulty finding a good aiming tutorial and this one perfected it and it was easy enough for me to copy it! you have earnt yourself a new subscriber!
this happens because your animation frames on the 60 arent correctly set so instead of copying both frames to 60 just copy the second then paste that to 60 so it wouldnt slowly drift to the first anymore
I always get the Error: NullReferenceException: Object reference not set to an instance of an object. I really don't know hot to fix that, I hope that you can help with my problem
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Aim : MonoBehaviour { public GameObject Gun; // Update is called once per frame void Update() { aimDownSight(); } void aimDownSight() { if (Input.GetButtonDown("Fire2")) { Gun.GetComponent().Play("aimDownSights"); } if (Input.GetMouseButtonUp(1)) { Gun.GetComponent().Play("New State"); } } } Here you go, all you need to do is change input method to get button down and set it to fire2. Make sure it's setup in project settings. (it is by default)
You have to go to your animations folder, click your aim animation, and uncheck looping in the inspector. I'm sure you've figured it out but I hope it helps someone.
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Aim : MonoBehaviour { public GameObject Gun; // Update is called once per frame void Update() { aimDownSight(); } void aimDownSight() { if (Input.GetButtonDown("Fire2")) { Gun.GetComponent().Play("aimDownSights"); } if (Input.GetMouseButtonUp(1)) { Gun.GetComponent().Play("New State"); } } } Here you go, all you need to do is change input method to get button down and set it to fire2. Make sure it's setup in project settings. (it is by default)
the most likely thing is that the name of the animation doesnt match the call to it in the script. if you named it the same as mine, check if the script is attached to your player? is the gun in the slot? and have you made the animation?
Thank You So Much! I'm Currently Making A Multiplayer FPS Shooter Game In Unity Every And Every Other Tutorial Didn't Work I Thought This One Didn't Work Too, But Then I Realized My Animation For Aiming Down Sights Was Called ADS Not Aim And I'm Very Glad It Works!
honestly this channel is a dream come true for me if had difficulty finding a good aiming tutorial and this one perfected it and it was easy enough for me to copy it! you have earnt yourself a new subscriber!
Thank you so much for this tutorial it helped a lot!
Thanks so much for wonderful tutorial simple and effective
Thank you very much. It helped. :)
When i right click, The gun goes all the way right and it keeps going right until i right click. Like wtf. Please help me
Thanks
Nice video
Thank You!
why does my firing animation stops playing when i aim down and fires?
When I press M2 it doesnt do anything, it just loads the new state animation over and over without moving my gun
I mean looks promising
Good video. It works! Any idea how to get a firing animation to work while ADS?
Thanks! I have a video uploaded on how to do ADS and in pretty sure this should work with it already on!
in a third person shooter game how to make it switch from third person to iron sight ??
you also need to code an animation to move the camera to the first person under downkey 1 and on upkey 1 new state
tysm bro !!!!
I can ADS fine but while holding down right mouse button the gun slowly drifts to another position
this happens because your animation frames on the 60 arent correctly set so instead of copying both frames to 60 just copy the second then paste that to 60 so it wouldnt slowly drift to the first anymore
when i look around the gun stays on the x axix and dosnt rotate with the camera please help
Is your camera the parent object of your gun?
@@NoblobRS no does it need to be ?
@@NoblobRS i fixed it lol, it was because the gun wasnt parented to my camera lmao. ty
I always get the Error: NullReferenceException: Object reference not set to an instance of an object. I really don't know hot to fix that, I hope that you can help with my problem
Did you find a fix for this. If so could you tell me what the problem was.
@@oGurk unfortunatly not
Make sure the name in line 5 (public class Aim : MonoBehaviour)is the same name you gave the script
Hi how do i make it zoom out smoothly too instead of snapping back
Just put the keyframes later. For example instead of 0:10 put 0:25.
i tried that and error in the consle :
Animator.GotoState: State could not be found
UnityEngine.Animator:Play (string)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Aim : MonoBehaviour
{
public GameObject Gun;
// Update is called once per frame
void Update()
{
aimDownSight();
}
void aimDownSight()
{
if (Input.GetButtonDown("Fire2"))
{
Gun.GetComponent().Play("aimDownSights");
}
if (Input.GetMouseButtonUp(1))
{
Gun.GetComponent().Play("New State");
}
}
}
Here you go, all you need to do is change input method to get button down and set it to fire2. Make sure it's setup in project settings. (it is by default)
Hi! When I do this, the animation just keeps repeating. Is there a way to stop this?
You have to go to your animations folder, click your aim animation, and uncheck looping in the inspector. I'm sure you've figured it out but I hope it helps someone.
@@estroyer9 Thanks for the tip!
How can I make it more smooth?
Just put the keyframes later. For example instead of 0:10 put 0:25.
it doesn't work when i fire my gun. what do i do?
What's your fire key? :)
Blend trees maybe? you could also make your own fire animation for aiming down sights which I would do.
add procedural recoil
it says invalid index layer -1 pls respond with a fix
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Aim : MonoBehaviour
{
public GameObject Gun;
// Update is called once per frame
void Update()
{
aimDownSight();
}
void aimDownSight()
{
if (Input.GetButtonDown("Fire2"))
{
Gun.GetComponent().Play("aimDownSights");
}
if (Input.GetMouseButtonUp(1))
{
Gun.GetComponent().Play("New State");
}
}
}
Here you go, all you need to do is change input method to get button down and set it to fire2. Make sure it's setup in project settings. (it is by default)
I have an error that says invalid layer index -1 please help
same
@@lungomungo look through everything and make sure it all matches, i fixed it and it was easy i just dont remember how
@@glowy6289 did u have any other animations like idle or reloading? and did u follow the exact steps in the tutorial? cuz mine still didnt work
@@lungomungo nope, and i did follow the exact tutorial
Is not do anything 😞😭
its not working for me can you help me ?
Sure! What part of it isn't working? Are there any errors or is it just not working?
@@NoblobRS When i press the mouse button it not zooming
the most likely thing is that the name of the animation doesnt match the call to it in the script. if you named it the same as mine, check if the script is attached to your player? is the gun in the slot? and have you made the animation?
@@NoblobRS i tried to put it on my gun and my weapon holder i didnt try player
Okay well make sure put everything in their slots. Also, it shouldn't matter whether its attached to your player or gun but its always worth a try!
something doesnt work :(
Do you know what exactly isn't working? any errors? is the whole thing just not working?
@@NoblobRS it has and error that reads "invalid layer index '-1'" idk what im doing wrong
@@NoblobRS Im having the same issue please respond with a fix
didnt work :(