PERFECT Weapon Aiming! (IK, Unity Tutorial Third Person Shooter)
Вставка
- Опубліковано 30 вер 2024
- 💬 Let's learn how to make a character aim perfectly at a target.
🌍 Get my Complete Courses! ✅ unitycodemonke...
👍 Learn to make awesome games step-by-step from start to finish.
🎮 Get my Steam Games unitycodemonke...
🔴 RELATED VIDEOS 🔴
Awesome Third Person Shooter Controller! • Awesome Third Person S...
Make your Animations DYNAMIC with Animation Rigging! • Make your Animations D...
How to get Mouse Position in 3D and 2D! • How to get Mouse Posit...
💬 Let's learn how to make a character aim perfectly at a target.
This is essential for making a good shooter controller, without it the character will simply aim straight forward towards wherever your animation is aiming rather than aiming perfectly at the exact position in the world.
This is pretty easy to do thanks to the awesome Unity Animation Rigging package!
🌍 Get Code Monkey on Steam!
👍 Interactive Tutorials, Complete Games and More!
✅ store.steampow...
If you have any questions post them in the comments and I'll do my best to answer them.
🔔 Subscribe for more Unity Tutorials / @codemonkeyunity
See you next time!
📍 Support on Patreon / unitycodemonkey
🎮 Grab the Game Bundle at unitycodemonke...
📝 Get the Code Monkey Utilities at unitycodemonke...
#unitytutorial #unity3d #gamedev
--------------------------------------------------------------------
Hello and Welcome!
I'm your Code Monkey and here you will learn everything about Game Development in Unity using C#.
I've been developing games for several years with 8 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.
I do Unity Tutorials on just about every topic, Unity Tutorials for Beginners and Unity Tutorials for Advanced users.
You can see my games at www.endlessloopstudios.com
--------------------------------------------------------------------
- Other great Unity channels:
Unity - / unity3d
Brackeys - / brackeys
Dani - / @danidev
Jabrils - / @jabrils
BlackthornProd - / @blackthornprod
Sykoo - / sykootv
Jason Weimann - / @unity3dcollege
Jonas Tyroller - / @jonastyroller
--------------------------------------------------------------------
- Website: unitycodemonke...
- Twitter: / unitycodemonkey
- Steam: store.steampow...
🌍 Get 95% OFF on Unity Mega Bundles assetstore.unity.com/?aid=1101l96nj&pubref=perfectweaponaim
✅ Get my Complete Courses! ✅ unitycodemonkey.com/courses
🔴 RELATED VIDEOS 🔴
Awesome Third Person Shooter Controller! ua-cam.com/video/FbM4CkqtOuA/v-deo.html
Make your Animations DYNAMIC with Animation Rigging! ua-cam.com/video/LEwYmFT3xDk/v-deo.html
How to get Mouse Position in 3D and 2D! ua-cam.com/video/0jTPKz3ga4w/v-deo.html
So what could the reasons be if it dont work at all?
Where did you get the standard animations you're using?
@@NordicNjal I do not know the reason.I only know if there is only one rig in rig builder,there would not be an error.I only know the result.
If anyone has this error - "The TransformStreamHandle cannot be resolved" - change the Rig object parent from Player Armature (the main Parent) to "Root" so the object stays near the "Hips" object
Yes rig has to be in the same parent as the root
-GameObject
--root
-head
-etc
--Rig
--Cam
Tnx Dud u r a hero
@@piotrgora5715 thanks GIGA CHAD
What if mine is still in the Root and still giving that error? Also by "in", do you mean, "a direct child of"?
Even as someone who works in Unreal, I can still learn so much from your videos!
Unreal has like it's own way of achieving nearly the same thing in a very similar way so I can apply a lot of your tutorials to my own projects as well. Thank you!
Likewise I watched an Unreal tutorial on making Genji's dash. And I could easily copy the logic and just write it in C# form.
I hope you are making an extended (paid) tutorial series for a GTA 3rd person game using Synty assets. There are probably 10’sk Synty asset owners who would buy that - maybe 100’sk Synty asset owners- partner with Synty Studios (who might provide a basic pack to go with your course) and you would have a massive market.
Thats a underexplored theme IMO, took hours searching to get a procedural lever pulling animation to work. Thanks for bringing it. It was on point =)
If anyone else runs into the " Cannot resolve because it is not a child of the etc etc."
Move your Rig 1 onto the character. If you are following along with Synty Assets, I put it under the Root (not in the Root, under)
Hope that helps someone else, this was an annoying issue.
Omg!!! I had the same issue! Thank you so much! It was so annoying 😅
Thank You so much for this info ....been battling with This since
you're a lifesaver, thank you
Yeah, I just ran into this and came to the comments looing for help. thank you! As much as I love synty assets, the characters do not usually play nice with animation stuff.
What do you mean by "onto the character"? The parent game object? Because that is what is a direct child of, and what holds the animator.
If anyone's simple Aiming ik is not working properly than u should bring the root (bone structure of the character ) at the same level in the hierarchy. I wasted 2 hours solving my buggy ik >﹏<
THX man!!! You solved my problem
can you please explain? I am having an issue and do not know by where in the hierarchy you mean for the root to be.
@@tacticalmythic7945 root bone and the rig of the character should be at the same level of depth in the hierarchy i.e. if the characters root bone is a child of a parent gameobject then the rig should also be a child of that parent gameobject. Rig cannot be a child of a child of parent gameobject
Can we all please get the full ThirdPersonShooter code from this video, because a lot of the code is now changed from the previous tutorial
Could you please also make tutorials for a First Person Shooter? That would be great!
Yup that's a topic I'd like to cover some more, I've only made one or two FPS tutorials so far
@@CodeMonkeyUnity that sounds amazing! I’m looking forward to it.
Nice video! Could you also make tutorial for this system with multiple weapons? I think it will be very good!
Sir Plz do a tutorial on Sword and Mele Combat...Thanks
Where did you get these awesome character locomotion animations?
great tutorial like always code monkey. Took a bit of a break (1 1/2 ish years ) from unity (working in Unreal engine for a bit), also starting College at University of Nevada, Las Vegas (UNLV) [Getting my degree in Computer Science]!
Great work!! Quick question, the code in this doesn’t line up with the code in the other video. I was wondering what video you have that goes through the shooting timing and such that lines up with the code used in this video? I have your coarse and looked through that but didn’t find the reference.
video was posted 40s ago and there's already comment
As soon I use the Multi-Aim Constraint my "Root Transform Rotation" Offset of 30° in the Pistol Idle Animation Settings (to correct the animation direction) is not working anymore and my character is rotation 30° to the left (offtarget) again. Any Ideas? (I am using Mixamo "Pistol Idle" Animation)
took another Animation which doesn't require Root Transform Rotation Offset to progress. But still want to know how to this kind of problem. Any Suggestion?
Same here, any solution to that? @@julezgg5974
Hey do you have a link to the new code you added to the thirdperson shooter controller? Its alot different from the first video with new methods 11:41
I just refactored it to match my coding style. I don't remember if the downloadable project files for the third person shooter already have that refactor, if not then the Ladder video should have it unitycodemonkey.com/video.php?v=44qVzrdvm04
@@CodeMonkeyUnity thanks
When using Animation Rigging, perfect aiming cannot be implemented because aiming is based on the hand bone rather than the weapon's muzzle!!!
its not working nothing is happening
You need to identify exactly what is not happening unitycodemonkey.com/video.php?v=KtY_5pDhqYY
Maybe you didn't add the Rig, maybe you didn't add the constraint, maybe it's something completely different.
Did you watch the Animation Rigging basics video? unitycodemonkey.com/video.php?v=LEwYmFT3xDk
There is only one rig in rig builder's rig layers?I put two rig in rig layers,there are two player's animation states, then there was an error : System.InvalidOperationException: The TransformStreamHandle cannot be resolved.This Exception was thrown from a job compiled with Burst, which has limited exception support.
4:44 Works sort of but the hand/cube child rotate awkwardly on the start so they no longer look like they're connecting to the target. Might this be an effect of using a different animation?
EDIT: Figured out the issue. It was that my model's hand local wasn't the same so I had to set
its aim axis to -Y and its Up Axis to -X.
Could not resolve 'PlayerArmature/Rig 1/AimObj' because it is not a child Transform in the Animator hierarchy.
5:24 Problem, and it's a bizarre one: The transformation gizmo is not snapping to the spine when I select it. Instead it stays on/snaps to the right hand again. Any idea why it would do this, and how do get around it?
EDIT: Deleting that cube object that was a child of the right hand seemed to fix it.
hey bro please dont stop making videos like brackeys you are simply amazing
Can you please explain how to get out of this constraint system smoothly to play eject and reload animations that line up correctly with the weapon? I've had trouble reconciling those, knowing what order to disable and play animations, whether to use animation or another constraint to grab the magazine, etc.
I wanna do the same with the gamepad rightstick but seems buggy, can you do a tutorial for similar scenario but with a Gamepad??
We need more of these tutorials CodeMonkey! 3D FPS Zombie Style 😎
Finally a well known developer youtuber made this.. been watching smaller youtubers tutorials and they out dated and were in a very low quality 😩
Sir could you please make a tutorial based on auto aiming like in multiplayer games like pubg ,free fire
is this project uploaded anywhere ? The code is different from previosu tutorial.
If you're getting errors , make sure the weapon doesn't have any children
Huh, 2 days ago. What a coincidence.
I am not making any 3D game right now, but it came to my mind to just search for upper body IK so in case I want to do an fps boss fight in later, I know what I'm... aiming to work with.
Thanks for this.
I love your every tutorials video 😍
Amazing! 🙏 Just one thing. Would it be too much to ask you to change your VS theme to dark mode? Unity is fine-(ish) but the VS editor is SO WHITE the photons destroy ones eyes 👀
Sorry I cant, dark mode burns my eyes
Don't forget to attach the Rig to the aimRig in the inspector.
The rigs structure dont work in case when ur using 3d starter pack of unity
Could not resolve bcz its not a child transform in animator hierarchy this warning appears
Property stream handle cant be resolved this error
Help please
Türkçe altyazıyı koyan kişinin eline sağlık ö-ö-ö-ö-ö-ö-ö-ö-öptüm bayy, gö-gö-gö-gö-gö-gö-gö-gö-gömmdüm say
How did you make these ammos and glowing ammos 😢😢
Glow is just bloom, on both the bullet and the TrailRenderer ua-cam.com/video/bkPe1hxOmbI/v-deo.html
@@CodeMonkeyUnity thanks for the Reply 💗❤️❤️❤️💗
Q.1
but i want to ask you that how did you make this muzzle flash effect and how can i make realistic one (not like this one but other ) because when i use point light it just shows on the walls and ground like surfaces there is not any visual light comming out of the gun like muzzle flash
Q.2
How can i get a job in gameDev even small job (with 50$ salary ) because here in india especially in my city there are literally no jobs for GameDevlopers
And i am ready for internship too if there are any
So if you know someone just let me no if they hire me i would love to in a Remote Job online
Im very good at c# Game Programming in 3D Games Unity
Please let me Know if you Know Someone ❤️💗💗💗💗❤️❤️
By the way love your Videos 💗💗💗❤️❤️💗❤️💗❤️💗❤️
@@CodeMonkeyUnity i want to know that how can i make my game playable multiplayer offline using wifi hotspot like Mini miltia (but now this game is online ) game and
Local Warfare Portable game
ty the best tutorial ever
all is working
Where you get the rifle animation like rifle walk and rifle run and the rifle idle ?
One good place to get free animations is mixamo unitycodemonkey.com/video.php?v=c4jtyDA7vcs
hi your videos are really helpful and help me a lot for my university assignment . However I'm still struggling on weapon pick up and changing weapon ,it would help a lot if you could do a videos on that ..... But even that you helped me sooo much . Thank you , Awesome content and easy to follow as well
The basics would be just a simple weapon pickup with a trigger collider to see when the player touches it ua-cam.com/video/Bc9lmHjqLZc/v-deo.html
Beyond that it really depends on how you implement it, you would need some script to manage switching weapons and keeping track of the active one. Then also change the visual which would possibly also require changing the IK rig (rifle requires two hands, pistol just one)
Thanks man, this is such a useful tutorial! And so on-point. I was having such a hard time getting the animation rigging package to work, since months. You my friend are a Godsend. Thank you so much for this!
Thanks for this tutorial, Unity really has a lot of amazing functionality already built-in
Están muy buenos los gráficos. Lo digo enserio. No sé porque no hacen más juegos así. Podrían meter más cosas si dejan modelos de bajos polígonos.
wouldn't it break(not work as intended) when the player moves close to a wall or object?
Check your raycast distance and if you are too close, don't aim.
It would look a bit odd but easily solved by just checking distance to the wall, if too close then just disable the rig
You can just move the spine
Hello i am doing the exact same steps as the video but it keeps giving me erorrs saying this:
Could not resolve 'Player/Rig 1/BodyAim' because it is not a child Transform in the Animator hierarchy.
i would really appreciate some help thanks
CodeMonkey pls help me good sir. When i click aim my character's hands are in perfect position holding the AR but when he is in idle position (not aiming), both hands are messed up and in the wrong place. How can i fix this?? Btw love your videos they've taught me so much!!
When Idle the animation rigging should not the active, you should disable the rig. If the hands are in the wrong position with the rig disabled then that just means the animation you're using is somehow broken
Either that or you're using animator layers and don't have the idle animation player on the hands layer
Your tutorials are so different bro! Always learn something new, even if I know some of it. Thanks
could you do a video on a third person camera using cinemachine
The basis for this character is from the free starter assets, you can look at that to see how the camera works ua-cam.com/video/jXz5b_9z0Bc/v-deo.html
Thank you very much
3:54 what if my downloaded rig have wrong direction? hand look at not to Z, but z+y (under 45 deg)
I want to learn to make my character shoot like yours. How do we do that? I've followed all videos related to 3rd person shooters but there isn't one with how you put the audio, the shooter effect such muzzle and the projectile
I covered the projectile in the Third Person shooter video unitycodemonkey.com/video.php?v=FbM4CkqtOuA
The particles, you spawn them on the same place as the bullet
The audio, you just spawn an audio clip unitycodemonkey.com/video.php?v=QL29aTa7J5Q
Can you maybe upload this project? I can't have the animation rigging set up nicely... it is so broken for me and I can't find any solution, having access to this will help me so much
Can you create a package from this project? with no-copyright humanoid models
Loved the tutorial! how do you get the projectile/bullet to look like that exactly? trying to make it in my game so that it looks like theres "tracer" fire from projectiles :)
The visual is mainly just a TrailRenderer with some nice glow ua-cam.com/video/bkPe1hxOmbI/v-deo.html
For the movement, the character does a raycast to find where the bullet will hit, then spawns the bullet object on the shoot position and that object (which has the trail) simply moves towards the target and destroys itself. No physics used in the bullet itself
@@CodeMonkeyUnity Ohhhh!!! thank you so much! slowly getting there c: your videos are a big help!
As of today I have bought all your courses 😊😊 keep sharing.. I like your tuts, they are really good and with lot of things to learn..
Thanks! I really hope you like them! Feel free to post any questions in the Q&A section!
Thank you for your work on this series of videos covering the different aspects of a third person shooter. I think what is missing from this series is how to handle strafing animations while aiming. Currently, the character's walking animations aren't realistic while aiming, with a sort of floating, moonwalking effect while aiming, the foot placement not consistent with the character's movement.
Hi. Your videos are amazing. How i can make one aim assist for third person shooter mobile? Have seme video about this?
Hi if possible can you tell me about animtion asset you used for shooting
It's from this pack assetstore.unity.com/packages/3d/animations/rifle-pro-mocap-animation-pack-46160?aid=1101l96nj
Great tutorial, thankyou. Issue I had is my guy holds his gun side on, applying a 45deg offset on the spines Y axis fixed that for me.
I just cant understand how u active that u can see what In game looks like while editing. I wish u could say it in the video
How I what? How I test the animation while editing? You need to enable preview mode, I talked about that in the animation rigging video unitycodemonkey.com/video.php?v=LEwYmFT3xDk
Thank a lot. But if i want to change the targetPositionWeight in my script. How can i do it?
You add the rig reference like I did at 11:35
Hello code monkey i have one question. How camera shake beautifully can you make the video on this topic.
Thanks
Don't make the bullet trails so orange!! Feels weird. Make it bright yellow pls
U so good, thanks u bro
I'm thinking about making all sorts of action games where this can come in handy😊🎉
But how do you know that the hand points exactly where the tip of the gun points?
What if you want to pick up the weapons though. I started working on something like that, but with hand placement. It didnt worked well. This video makes me wanna go back to it
I was also exactly having the sa expressions LMFAO
Tell us how it been!!
One of the more confusing tutorials I have seen on this topic, although in general I really like Codemonkey's tutorials. I have followed the third person shooter controller tutorial diligently, but there is a huge gap on where that left off and where this starts. We didn't have a weapon there, and the character is just swinging their arms around when walking. I do not understand at all where this vid is supposed to start - what animations need to be in place? From where? It is definetly not the free unity 3rd person controller neither the pistol idle animation we downloaded in the previous one.
The weapon is just a mesh placed on the child of the hand bone, that's it
Not sure what you mean by "swinging their arms around when walking", that's just the walk animation?
You use whatever animations you want, if you want a pistol animation then use that same pistol animation, if you want a rifle animation then you need a rifle animation. There's tons of animation packs on the asset store, or alternatively look for some free ones on Mixamo.
@@CodeMonkeyUnity thanks man! what I meant is the previous video of the series finished with a different character model, that is in a different default pose, has different animation set, and is without a weapon - I tried adding a weapon as a child and rotate it around, but the robot had a V shape at the start, and also the gun never got a blue bone rig like in yours - and in idle state behaved differently too as the animations I found online were different. And as a beginner this made me look for a different tutorial altogether, as I couldn't recreate your starting state in like 2.5 hours. This also included quite some time until I figured out that I need to configure the imported aim animation to have rotation Original and baked into the pose. I always found your tutorials easy to follow, so thats why I mention it here! have a great day!
Is there anyway to chat with in discord I need advice I don’t want to be viral
going well. For so reason tNice tutorials video struck as really concise and really cleared up so questions I had. The DAW I used back in
Please make one tutorial on full body fps.. Using Animation rigging package, how head stablize with mouse movement
Can you please make a video teaching us how we can make wall running for third person
How did you do the cinemachine impulse please when shooting ?
If I were to be using a weapon system where I switch between a Handgun and a riffle, how could I setup the IK for each and then use
The hand is not following the sphere as instructed
Check your forward axis, maybe your model is rigged in a differnet way
For some reason my vectors on my hand differs from the other one. Basically one direction on my hand converts to a green. They aren't on opposite sides but instead just random. Idk how to explain but it's driving me nuts
Maybe you have a model that was rigged incorrectly, I believe the model I used in the video has the standard rigging but there's no hard rule that says it must be rigged exactly like that, it's up to whoever rigged it
Thank you for your response! I just went by trial and error and tried different values until it worked. It was actually Y + Y for me. Weird (imo) but it was easier when doing the other one cause that one I could figure out. @@CodeMonkeyUnity
Una pregunta la ppse de sostener el arma como se consigue veo q la tiene s desde l inicio
It's simply placed as a child of the hand bone, I set it up in the previous video ua-cam.com/video/FbM4CkqtOuA/v-deo.html
Do you think you can make an Ik tutorial on how to walk up stairs
I finally decided i want to learn how to make games so I found your channel, loved it and watched the entire TOP10 games series plus some more and finding out you were Portuguese made me really proud for some reason. I love when channels I enjoy are from our little country. Congrats on the content.
Thanks! Best of luck in your learning journey!
@@CodeMonkeyUnity thank you 😊
Hey, i just completed both tutorials and i just got to say it, they were really useful, and everything ended up looking professional. Iused the mouse sphere and it didn't work right (when sudden changes in deepness, the spine IK turned too fast), but i created an gameobject 10 meters on the z axis of the main camera and it worked amazing. And I just lerped to create a smoother movement between the position and the positioni it should aquire when following the gameObject in font of the camera that i created. I am really happy and I hope you keed doing third person shooters. A cover mechanich and simple IA that also uses it and you just got a full game.
I'm glad the videos helped you! Smoothing can definitely help if you're going for a super fast twitch shooter
Could you maybe make a little Tutorial on adding Google account to a Game for e.g. saving Highscores, or even better, a semi-multiplayer high score where the game itself is singleplayer, but the high score of all players could be seen, maybe with firebase? as always, keep up your good work.
Are you using freelook camera for tps view?
TNice tutorials is going in my helpful tutorials playlist.
i have fps hand anim how to combine it with humanoid character
please use dark theme because i hate light theme it burn my eyes
Sorry but dark theme burns my eyes
Thank you very much for your videos, I wanted to share that the constraint for the left hand is better set with Chain IK Constraint.
This is probably the best Third Person aiming tutorial available anywhere, either free or paid . BUT, I keep coming across a problem where if an object (ie an enemy) comes between the gun and the camera, my character tried to shoot backwards and everything breaks for a second..... I have seen a very complex solution to the problem, but wondered how you would approach it ....
The super simple solution is just add a distance check, if the enemy/target is too close then disable the IK aiming or make the weapon aim straight down. It's up to you if you want to allow the player to shoot when so close or not, some games allow that and some dont
in the mouse thing to make the target move with the mouse, you didnt explaine how to do it to work if you aim at the sky
You place an invisible collider in the sky and it will hit that collider, I covered that in the third person shooter video before this one ua-cam.com/video/FbM4CkqtOuA/v-deo.html
@@CodeMonkeyUnitythank you it was my mistake❤️❤️❤️
Great work I want to make something more like risk of rain 2 where the character can always shoot in third person mode with out aiming for you have a tutorial on that?
Revisado
Yet to watch the video, but the thumbnail of this video and title are way better than your usual go to. The only thing I can suggest is to increase the contrast of the thumbnail and use colors that are like candy to our eyes. Bright but not generic colors, colors like cherry red/lime/hot pink/azure. Also maybe give complimenting colors a try :D
Sorry but i followed you first vid and it was cool and working perfect until i got the error that tells me the avatar is invalid and it doesnt play animations EVEN the ones that doesnt need ik. And my character just freeze on the T-Pose ... HELP ME Please
Sounds like maybe you're using the wrong avatar, you need to use the exact same one generated for that mesh, different meshes use different avatars unitycodemonkey.com/video.php?v=AO1vw-b8Qzw
I followed your video, it works fine except when I am close to wall, how can I fix it?
Calculate the distance towards the wall, if too close either ignore it or aim the weapon up/down
@@CodeMonkeyUnity if you could do a short video it would be so much help!
I'm sure ill find an answer, but how did you add a bone structure to you gun like that?
The gun doesn't have bones, the bones are on the characters hands, the gun is simply a child of the hand bone
@@CodeMonkeyUnity Thank You
is there any chance getting project files?
Maybe I was too dumb to understand, but one of my characters doesn't have a weapon (he uses his mouth to pull objects towards his mouth) and the other character has like a slingshot attached to it's arm (They're not human shaped, they're more like live toy dolls). If it's the mouth one can I skip the first weaponAim step and go to the body Aim one without trouble, also I don't have a physical target object since my aim is working with raycasts
Plus: what's the Rig object you have on the start of the tutorial I pressume is from another video, do I need to do everything from that video or is just adding a component and that's it?
The Rig object is from Unity's Animation Rigging unitycodemonkey.com/video.php?v=LEwYmFT3xDk
It has tons of constraint types, you just have to choose the right one depending on how your non-humanoid characters are set up