💬 It took a lot of work to make this video but I'm really happy with the final result! I hope you like it! ✅ Get the Project Files unitycodemonkey.com/video.php?v=FbM4CkqtOuA 🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses 👍 Learn to make awesome games step-by-step from start to finish.
I'll be real with you, channels such as Code Monkey and Brackeys are the reason I chose Unity over Unreal when it came to answering "which engine?" The quality and accessibility of tutorials such as these _cannot_ be overstated. Thank you for all the terrific content, and keep doing what you do! You've earned another subscriber/supporter!
its finally happening! Im really hoping for a melee combat tutorial that expands upon the 3rd person starter assets. would it be possible to have the melee combat have animations where you dont just animate the upper body to perform melee attacks? like if you do a melee attack, you wont be able to move until the melee animation has finished playing like in most action games? a combo and targeting system would also be nice :)
If anyone is having difficulty aiming and walking at the same time, you need to create an Avatar Mask. Open up "Humanoid" in the Avatar Mask and deselect the legs and lower IK so that only the upperbody is green. Then, click the cog wheel on the Aiming layer and add the Avatar Mask to the Mask field. This will make it so that when aiming, only the upper body bones are affected and you will still be able to walk as per the Base Layer animations.
Great point, In addition to this, make sure you set your model to humanoid. After you import your fbx file, under the inspector, select "Rig" and then choose "Humanoid" under the animation type. This will allow you to switch layers and also prevent the bug of (the character from showing halfway through the ground).
@@noblephantasms7250 You can do this by Right Clicking Create go down to Avatar Mask. From there I clicked on the legs, body and the bottom 1ks. Then on your Animator and your Aming Layer, click the gear icon, add the mask you just made and click on IK pass.... This is what I did any way works for me :)
for those stuck between 20:00-23:00: 1. make sure the BulletProjectile script is on the pfBulletProjectile prefab (click the prefab and drag the script on). 2. Also, click on the prefab and make sure Use Gravity is ticked off. Still following the tutorial, but was stuck for a good while on this. Good luck! update: works perfectly thank you so much this is an amazing tutorial
SOOOO first go-round I broke everything at 7:00 into the video. My error was that Code Monkey quickly attaches the script for toggling between the zoom and normal camera that I missed that he had attached the PlayerAimContorller script to the PlayerAmature rather than the PlayerAimCamera. I have about a weeks worth or Unity so for anyone else that hits this error hope this helps.
I know how to fix it... just open your thirdpersonshooter script and change private void"awake" and "update" to "Awake" and "Update". (capital letters)
i know im late to the party and i might have missed it but i did also have about 100 errors rolling in a minute when i had hit play to test out the zoom, what fixed it for me is under PlayerArmature, the ThirdPersonShooterController script, i dragged the PlayerAimCamera into the Aim Virtual Camera, and the errors went away and is working as it should be. hopefully that helps anyone out that might be having that issue or overlooking something potentially simple.
Another great tutorial, thanks a lot! Also I think I found a neat solution for aiming in the sky (14:02), without needing boundary colliders everywhere. If the raycast returns false move to an else block and create the aiming point by projecting a vector in the direction of the camera orientation, from the camera position, at a desired distance from it. For example I set mine to 200: if (Physics.Raycast(ray, out RaycastHit raycastHit, 200f, AimColliderLayerMask)) { DebugTransform.position = raycastHit.point; } else { DebugTransform.position = _cam.transform.position + _cam.transform.forward * 200f; } Let me know if I am overseeing something and there is a problem with this, but thanks again for the video.
@@alovelygondal7673 Hi, this is in relation to the main camera. if you want you can use this instead which will work as long as you have one main camera. else { debugTransform.position = Camera.main.transform.position + Camera.main.transform.forward * 999f; }
For bullet not working, : - Add the bullet script to your bullet => he not showed it but it said it (i realised that after 10x watching haha) - Make your bullet a prefab, drag and drop it in the prefab folder. Than delete it from the scene, and drag and drop the prefab in "Bullet Projectil" from thirdPersonShooterController on the playerArmature - If it bounce/not destroy; make the colider a few bigger than the cube
For the hit scan on 27:08 if the particle shows up on the feet it is because it is using the player transform position. Make a var called like hitpoint, similiar to the debugTransform, in the 'raycast IF statement' set the new var hitpoint to the 'raycastHit.point', and in the shoot instantiate code replace transform.position to the hitpoint variable. Thanks for the tutorial, learned alot!
Also for the crosshair if anyone wants an easy way to enable it when aiming and disable when not you can add [SerializeField] private GameObject crosshair; // makes a serialized field for the image of the crosshair to be assigned to. In Awake: crosshair.SetActive(false); // hides the crosshair to make sure it is hidden at the start. In Update if (starterAssetsInputs.aim) // if the user is aiming { crosshair.SetActive(true); // set crosshair to enabled. } else // if they are not aiming { crosshair.SetActive(false); // disable the crosshair } Then in Unity drag the crosshair image onto the serialized field. Hope this helps anyone who wants this easily. The full code up to the crosshair section for me is: using System.Collections; using System.Collections.Generic; using UnityEngine; using Cinemachine; using StarterAssets; public class ThirdPersonShooterController : MonoBehaviour { [SerializeField] private CinemachineVirtualCamera aimVirtualCamera; [SerializeField] private float normalSensitivity; [SerializeField] private float aimSensitivity; [SerializeField] private GameObject crosshair; private StarterAssetsInputs starterAssetsInputs; private ThirdPersonController thirdPersonController; private void Awake() { starterAssetsInputs = GetComponent(); thirdPersonController = GetComponent(); crosshair.SetActive(false); } private void Update() { if (starterAssetsInputs.aim) { aimVirtualCamera.gameObject.SetActive(true); thirdPersonController.SetSensitivity(aimSensitivity); crosshair.SetActive(true); } else { aimVirtualCamera.gameObject.SetActive(false); thirdPersonController.SetSensitivity(normalSensitivity); crosshair.SetActive(false); } } }
is there any way that this virtual camera only follows characters back and on look input its works same before ...if character rotate than the virtual camera shoul have to rotate as to follow charcters back
The instantiating bullet can be used in a realistic game as then we can set the spawn point in the guns barrel and then if this happens( 27:54 ) then it shows that the bullet actually spawns from the guns itself and not from the middle of the screen, many realistic FPS/TPS games do this thing and it adds that extra bit of realism to the game really cool, raycast can be used for a more arcade shooter
I saw an error: @ around 27:20, near the ending of the Raycast shooting tutorial, the Instantiate methods are spawning the particles at transform.position, aka the player position. This makes the particles spawn inside the player. It should be changed to mouseWorldPosition or debugTransform.position which is the raycast.point value of where the raycast hit.
Its funny when you do it because it looks like the character is exploding! Could you maybe add or explain the steps to get the Pistol Idle animation from Mixamo? I can only download the entire mesh, I dont know how to extract the .animation file from the .fbx
@@chrheca Click on the arrow icon to expand the object, inside is the animation, click on it then Ctrl + D to duplicate and it will duplicate it outside of the .fbx as a separate asset
If you want the crosshair to only appear when you right click (like in a non-shooter focused game with shooting mechanics) then make a new script with this: using UnityEngine; using System.Collections; public class Cross : MonoBehaviour { // Graphic used for crosshair public Texture2D crosshairTex; // Rect for crosshair size and position private Rect crosshairRect; // bool to turn crosshair on and off public bool IsCrosshairVisible = true; void Awake() { Cursor.visible = false; crosshairRect = new Rect((Screen.width - crosshairTex.width) / 2, (Screen.height - crosshairTex.height) / 2, crosshairTex.width, crosshairTex.height); } void Update() { if (Input.GetMouseButtonDown(1)) { IsCrosshairVisible = !IsCrosshairVisible; } if (IsCrosshairVisible == true) { IsCrosshairVisible = true; } else { IsCrosshairVisible = false; } } void OnGUI() { // draw the crosshair in center of screen if (IsCrosshairVisible) GUI.DrawTexture(crosshairRect, crosshairTex); } }
@@CDisplay-o9t that works. I actually used this line of code(input.getmousebutton down and up) to make the aiming instead of using the new input system. Works well for me!
Thanks for the tutorial. It really helped me to move forward my project. Here is a tip:- Instead of placing cubes around the environment for player. just get a point from ray at a distance. Ray ray = _cam.ScreenPointToRay(screenCentrePoint); debugTransform.position = ray.GetPoint(20); GetPoint will give you at point on the ray at the distance you have given. so even if player is aiming at the sky it will work without placing collider around environment.
Vector2 screenCenterPoint = new Vector2(Screen.width / 2f, Screen.height / 2f); Ray ray = Camera.main.ScreenPointToRay(screenCenterPoint); if (Physics.Raycast(ray, out RaycastHit raycastHit, 999f, aimColliderLayerMak)) { debugTransform.position = raycastHit.point; } else { debugTransform.position = ray.GetPoint(20f); } Like this right?
If anyone is a fool like me, make sure you also set the moustWorldPosition = to the ray.Getpoint() otherwise when you aim at the sky your not getting that variable updated.
Edit: This does fix the abrupt change of aim when going from one target to another, but the aim is no longer accurate. I think I'll have to find a way to smooth out that abrupt change. ____________________________________________________ Great idea, thanks. Additionally, I would say that when you're aiming at objects other than sky, still better to use debugTransform.position = ray.GetPoint(20); because in this way your aiming will stay smooth. If debugTransform keeps jumping from object to another, your character's aim abruptly changes, which in my opinion is not desirable (at least for my game design): Here's the code : Vector3 mouseWorldPosition = Vector3.zero; Vector2 screenCenterPoint = new Vector2(Screen.width / 2f, Screen.height / 2f); Ray ray = Camera.main.ScreenPointToRay(screenCenterPoint); if (Physics.Raycast(ray, out RaycastHit raycastHit, 999f, aimColliderLayerMask)) { debugTransform.position = ray.GetPoint(20f); mouseWorldPosition = ray.GetPoint(20f); } else { debugTransform.position = ray.GetPoint(20f); mouseWorldPosition = ray.GetPoint(20f); }
When you turn the character to the direction you're aiming, you use Lerp with the current position in the first argument. Lerp really works when you continually provide the original starting value and a final value on every frame. If you don't want to keep track of the original starting value, use MoveToward or RotateToward instead. The progression of values you get with Lerp are only linear if you use it as designed, with the original starting value on every call.
Can someone help me i am stuck at this error : my player doesn't shoots whenever i try to shoot this error pops up: MissingReferenceException: The object of type 'Transform' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, UnityEngine.Vector3 pos, UnityEngine.Quaternion rot) (at :0)
You should do a tutorial on a First Person Controller setup with full body awareness and animation rigging. I just realized while putting mine together that there are no real good tutorials for that out there for reference so I had to do mine all by scratch. It was actually more tricky than I expected. I never realized things like keeping the head and body separate for networking reasons. Or how difficult it really is to get the body to perform like an actual body in relation to eye sight and the hands/gun movement.
i love this tutorial and everything was going smoothly until i finished the bulletprojectile script... the bullet would spawn in the scene but it wouldnt have any velocity, it just spawns and stays still. anyone had similar issues? ive rewatched and checked my scripts 20 times, still no fix
Bro i just fixed it what was the mistake is that in I forgot to writeline that was mouseWorldPosition = raycastHit.point; in ThirdPersonShooter Script in : if (Physics.Raycast(ray, out RaycastHit raycastHit, 999f, aimColliderLayerMask)) you also check it as his video is so fast that I didn't even noticed even after watching 10 times
I've been searching online for a true first person shooter controller Tutorial and found nun if you could make one that would be amazing for those of you who don't know what a true FPS is it's like a third person controller it uses third person animations and a full body but the camera is mounted on the head games like escape from tarkov and arma 3 use it
Great walkthrough CM. I was wondering if you experienced problems with the mixamo weapon related anims. Im experiencing a problem with ALL the weapon/aim anims from mixamo when applying the 'aim' animation layer mask weight to 1. Before applying the weight the character is facing straight forward in the idle animation like normal but when i make the weight 1 and activate the aim anim the character does not aim straight forward but to the left. So he goes from facing north to facing north west when the animation layer mask is applied. When setting up animation rigging to correct this the character just falls halfway into the ground and doesnt perform the idle animation but instead is just frozen in a weird pose.
I haven't encountered that issue but if you select the FBX file you downloaded and look in the inspector import animation settings you can change lots of things including applying a rotation offset
@@Luffius I had this same problem, if you go to the inspector for the animation, then go to animation window and go down to motion you can set it to the joints of the PlayerArmature or whatever you want it to rotate towards at the start of the animation. This is using the root motion node.
Bit late for an answer but if you select the animation taken from Mixamo once imported select Animation tab then scroll down to Root Transform Rotation and set it from Body orientation to original that should sort the aiming offset out.
I'm having this weird issue where after I complete the work from the aim input section my camera starts moving weirdly, it starts teleporting instead of smoothly moving on screen.
I had the same issue. I tried EVERY fix I could Google. What finally "fixed it" for me was just closing Unity, playing Rocket League for a little bit and then coming back to it. I don't know what the **** happened in between but restarting Unity and going right back in, did NOT work. But coming back an hour later did? I have no idea. Its the second time I've come across this issue and the second time that little "turn it off and come back later" fix worked. I know its not exactly a solution but, that did it for me so I figured I'd share.
So this worked for me. I selected the PlayerArmature in the Hierarchy then in the Inspector I expanded the PlayerInput component and then clicked on Open Input Settings button. In the settings window I changed the Update Mode to Process Events in Dynamic Mode and that fixed it for me. Not sure about the trade offs of selecting this Update Mode though.
Hi dude at 13:00 when I attach the sphere to the debug transform and play the scene nothing happens the sphere stays where it was placed and it does not follow the camera
tbh the controller from Unity is kinda trash since the jump and everything is basically hard coded, if you want to do something like removing the player control after jumping you basically have to rewrite everything
I like using FSMs. Tried this for the first time after writing different controllers bc it takes a long time to get everything nice and polished. Immediately hated it. I cant come up with game ideas anyway, so I'll just keep working on third person character controllers
Hello code monkey i am facing a problem in my unity editor.There is a compiler error from a script that i didn't create and i don't know how to fix the error and when I open my asset in package manager it shows a error and then crashes i am using unity 2020.3.3 please tell me how to fix these problems i am just a 12 year old boy and i really need unity to create a game
33:21 This part does interest me a lot since it's one of the things I've had issues with for upper body aiming. I tried IK but it didn't quite work out as I wanted.
hello code monkey!! great tutorial but it seems like im stuck at 17:00 my character somehow doesnt face in the aimed direction but instead he turns away from it....idk what i could've done wrong and need ur guidance to solve this issue....
Does the walking rotate correctly? Only the aim has issues? Pause the game and look at the character, is the transform rotated? Or the animation? Look in the animation import settings and make sure it's not rotated by default, you can bake a rotation override
Excellent tutorial! I had already got a basic combat system going with the Third Person Controller, but I was not at all happy with the camera. This tutorial made it all right as rain, thank you! :)
Can you make a video on how you polished everything at the end? Because I have the animations and functionality down, but it would be very helpful if there was a video showing how to add for example a walking animation while aiming, all the FX used and so on. Other than that this video was great and really helpful :)
I'm planning on doing a video on animation rigging which is what I used to make the weapon aim at the target For walking while aiming, that's just adding a Avatar mask on the second layer and only overriding the upper body, leaving the legs to walk
@@CodeMonkeyUnity Hey Code Monkey! What if I want incorporate a different movement animation while aiming? How does that work? Can you please make a video on that one or could you briefly explain it?
I absolutely love this video. Right up to the point of adding a point animation. I can't find anything easy to follow that will allow me to add animations to the standard unity third person controller.
I figured this issue out for anyone else that might come across the same problem. I did this - Go to the "Rig -> Animation Type" and change from "Generic" to "Humanoid" and click on "Apply". That fixed it.
When i finish until 28:00 I have two problems: when we use the logic without the projectile the particle does not apear and with the projectile when I shoot at least 10 bullets thew system says that the transform has been destroyed and I cannot call the variable INSTANTIATE! what could be
Thanks for the tutorial. But I have a question in the Animation section. I followed the steps like you showed at 29:20 and gave the "Aiming" layer a weight of 1 but for me it still is in the Idle animation of Base Layer. I can see that the Pistol Idle animation is playing as that blue line of progress runs on that state, but in the Game window, the character doesn't actually follow that animation but rather is still in the base layer idle animation. Any ideas as to what could be the issue here? Thanks.
@@CodeMonkeyUnity I replied a follow-up after a couple of days, but it's gone for some reason. Thanks for the prompt response from your side. Anyway, figured this issue out for anyone else that might come across the same problem. I did this - Go to the "Rig -> Animation Type" and change from "Generic" to "Humanoid" and click on "Apply". That fixed it.
if you feel that the camera lags when you move the mouse, you can try this solution found on Unity forum : 2021.2.7 uses version 1.2 of the Input system package which has an issue with inputs delta when set to fixed update and can cause the lags you are seeing. To check if that's the issue you could try this: Edit -> project settings -> Input system package If Update Mode is set to Process events in fixed update change it to Process events in dynamic update I hope this will help you and thank's for this tutorial :)
Great little tutorial. I liked the new input system you are using compared to the old one. The coding you added for the third person controller was also pretty informative. Gotta save this to use later if I get around to doing a tps shooter demo in the future.
Code Monkey, you have outdone yourself. This is so fantastic. It also provides a great framework to expand upon. Thanks so much for providing so much learning for no cost to the viewer! Youre doing the community such a wonderful service. We are all so very grateful for your time and hard work helping all the little guys and gals out there trying to get better! Thanks!
@@CodeMonkeyUnity Great video. Could you tell us anything about the post processing you have set up? Is that just the demo scene in URP or are you using custom PP? I ask because I'm using HDRP and my demo scene doesn't look anywhere as nice as yours. Thanks for the great content. Liked and subscribed :D
Hi ! Thanks for the tutorial but I have a problem at 24:00. My projectiles, instead of going straight into where my mouse is like in the video, they fall directly to the ground when I press my button to shoot. Do you have a way to resolve this? Thanks and I'll stay tuned
I was going to make a system based off of the video "How to make ALL kinds of GUNS with just ONE script! (Unity3d tutorial)" by Dave / GameDevelopment @davegamedevelopment but it is done in the Input.GetKeyDown system, how can change that system to use it on the unity starter assests input. Could you make a video like the video I showed but for the new system because I really want the stats to be easily changeable, as there will be many guns in my game. Thanks!
I just wanna point out this guy still answering questions in more than a 1 year video. True Legend!!! in 18:40, I want my character to be constantly fasing the way I'm looking and don't have an aim function. So I just used the code out of if statement and still works great! My only problem is, because player is actually looking to raycasted object, for example if I push my right shoulder to the wall and look at the wall, because of the perspective, object actually moves behind the character and causes to player to actually look back. Is there a possible way that I can fix this?
Heh yup as long as someone posts a comment on the video an not on a reply I'll probably see it the next day. For that issue the best solution is to look at how far the target object is, if it's too close then don't look at it. Either lower the rig weight or define a point a certain distance in front
@@CodeMonkeyUnity Thank you so much for the reply I'll give it a try. Another problem is, I'm running all this on Netcode. Because I don't want other players to shoot for myself, I put my aim point and muzzle point in my player prefab, and then made them separate prefabs so I can reach from transform function. Right now my bullets spawn, but doesn't spawn in my muzzle point, instead spawn at 0,0,0 and doesn't move. What should I do?
Hello Code Monkey, its a update on the asset pack and when I was going to multiply the Camera Rotation it says //Don't multiply mouse input by Time.deltaTime; And instead of Time.DeltaTime it says deltaTimeMultiplier. Please Help.
@CodeMonkeyUnity can you help me in how to fix the error "The type or namespace name 'cinemachinecamera' could not be found (are you missing a using directive or an assembly reference?" what should I do
14:26 A more simple solution if(Physics.Raycast(ray, out RaycastHit raycastHit, 999f, aimColliderLayerMask)) { debugTransform.position = outhit.point; } else { debugTransform.position = ray.GetPoint(30); } When there isn't a collider in front of the player, the target point will be a little bit away from him if you write this code.
when importing the pistol idle animation I downloaded from mixamo and putting it on a separate layer it doesn't do anything even after changing the weight to 1, anyone else come across this and worked out what it might be?
can anyone help me with this error? error CS1519: Invalid token ';' in class, record, struct, or interface member declaration. At the end of [SerializeField] private float Transform debugTransform;
could you help me when I'm turned on my back and aim forward my character the x axis moves that is it does a somersault when I look at the sky could you help me thank you
I just Imported the Assets and everything is Pink for some reason. I just don't understand how to fix this are the assets broken now or is something wrong with my unity version? How do I fix this? Please reply as soon as possible. Btw love your videos!
@@CodeMonkeyUnity MissingReferenceException: The object of type 'Transform' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object. UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, UnityEngine.Vector3 pos, UnityEngine.Quaternion rot) (at :0)
Hey @CodeMonkey Bhai mai ik game bana raha hu , so i want that can you make a detailed video on "Infinite Procedural terrain generation" and " How to make animation of NPC's Like GTA-6 "that they are interracting with temselves like a real human . In terial is See that the NPC's are passing WaterBottels And Playing Basketball . And Like I give an example If The Frankline Goes To A Rich Colthing Shop the Owner Call The Police But Don't call Police When tere is another Game Character And Like If In Eveing You Comes Near To Girl It calls Police and Police Caught You Like That . Please make video on it .
This is Great I have purchased the Space Combat kit from unity and I would like to implement my character with this into it. It would be awesome if you can do a tutorial on the space combat kit and implementation of this.
Hi @codemonkey newbie here, I have been trying to modify the movement script so that when the player presses A or D, the character doesn't rotate, instead, the character just moves to the side without rotating, so, aiming to the front all the time but still moving to the side, like a strafe motion. But I have failed. Would you please give me a hand?
the following is not working correctly for me. I don't know why it worked in the video. lo siguiente no me funciona correctamente. No sé por qué funcionó en el video. if (hitTransform != null) { if (hitTransform.GetComponent() != null) { Instantiate(vfxHitGreen, transform.position, Quaternion.identity); } else { Instantiate(vfxHitRed, transform.position, Quaternion.identity); } } pero lo reemplace por if (hitTransform != null) { if (hitTransform.GetComponent() != null) { Instantiate(vfxHitGreen, mouseWorldPosition, Quaternion.identity); } else { Instantiate(vfxHitRed, mouseWorldPosition, Quaternion.identity); } }
what do you mean by that!!! (I'm seeing errors related to LWRP or Light2D? Some projects were made before Unity renamed LWRP into URP so they contain the old namespaces, just change them into the Universal namespaces and everything should work.)
@@CodeMonkeyUnity what does that eror mean?( 'PlayerArmature' Animation Event 'OnLand' on Animation 'Walk_N_Land' has no reciver! Are you missing a component? )please i cant move
Hello Code Monkey and everyone, can you guys give me some solutions about why do the bullets i fired falls down to the floor instead go straight to the target crosshair? I have followed all the tutorial in this video from 19:31 to 24:00 and still can't figure out what i missed. Every answer you guys give will mean a lot to me. Thank you before.
Disable gravity on the bullet. Add some Debug.Log to make sure you're setting the velocity correctly. And make sure you're not spawning inside the player collider, or make sure there's no collider right in front of the spawn position.
@@CodeMonkeyUnity Actually i forgot to insert the Bullet Projectile script into the pfBulletProjectile because i didn't see it in the video. After adding the script, everything goes well. Thank you for answering. I'm looking for you another great tutorial.
help getting this error 'CinemachineVirtualCamera' does not contain a definition for 'gameobject' and no accessible extension method 'gameobject' accepting a first argument of type 'CinemachineVirtualCamera' could be found (are you missing a using directive or an assembly reference?)
Use a collision to test if you have touched the weapon to pick it up ua-cam.com/video/Bc9lmHjqLZc/v-deo.html Then you could toggle a simple bool to allow the player to use that weapon
What is the best way to expand this controller: to add your code inside the existing script or attach another script to an object and add more logic there?
Depends on what you want to add to it, if its adding some other feature like Auto Aim, I would make it in the same script, if its adding a complex weapon manager logic, I would make a separate script
How to create Character Controller swimming on Water surface and underwater Character Controller doesn't Support Rigid body and gravity I don't know how to Create swimming please reply me Sir
Love the content, but could you slow down some. You type at full speed and then scroll as soon as your done to the next spot. Very hard to follow along without pausing and rewinding every few seconds.
I love video, its super helpful! Question tho, at 15:15 you have the debugTransform sphere slowly approaching the armature, but at 15:16 it jump cuts and this issue no longer happens. How did you stop the debug sphere from moving toward player, I'm having this issue and don't know how to fix it?
Remove the collider on the sphere. The issue is the raycast hits that collider which means the next position is a tiny bit closer, then it hits again and so on and on
@@CodeMonkeyUnity THANK YOU! I would have never been able to deduce that, I cant believe its that simple. Thanks for teaching me the reason "why" for this behavior as well. Ive learned a lot from you :)
Hey, I have a doubt. We can't use your project files for commercial purposes, right? As they are part of the Synty battle royal pack and to use your project files commercially, we would need to get that pack right? If yes then it will be nice if you mention this in your video so that everyone is aware of this.
I can see a bit of a flaw in the execution here, what happens if you stand directly to the left of a pillar? The camera & crosshair will be in front of the pillar, and your bullet will fire backwards. I'm not sure what the best solution would be though, perhaps offsetting the starting position of the raycast forwards to the minimum distance in front of the character/camera that you want them to be able to shoot?
💬 It took a lot of work to make this video but I'm really happy with the final result! I hope you like it!
✅ Get the Project Files unitycodemonkey.com/video.php?v=FbM4CkqtOuA
🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
Also u want to continue mobile 3rd person shooter
Sir, need new unity mega bundle review🙏
aw man i love u tnks
Look My Channel, Im Make A Mobile Legends 2D Version, Thank You😁🙏🙏
It is so usefull sir. Can you please suggest any video, how to attach weapon to the player, like you used
you can put and "else{ mouseWorldPosition = ray.GetPoint(10);}" after the raycast so you dont need a collider for the skybox
Thank you so much
One of the most usefull comments on the UA-cam. Thank you!!!!
EXCELENT
I'm not sure how to implement this, unity says "mouseWorldPosition" does not exist in this context'
@@tartoras look the script in the video, he created a Vector3 called "mouseWorldPosition"
I'll be real with you, channels such as Code Monkey and Brackeys are the reason I chose Unity over Unreal when it came to answering "which engine?"
The quality and accessibility of tutorials such as these _cannot_ be overstated. Thank you for all the terrific content, and keep doing what you do! You've earned another subscriber/supporter!
I'm glad the videos helped you! Thanks!
@@CodeMonkeyUnity why will nothing move or respond in the scene
@@alsgaming1426 make sure scripts and stuff are attached?
@@jaybehl7567 yes they are
@@jaybehl7567 But where to attach BullectProjectile script ?
its finally happening! Im really hoping for a melee combat tutorial that expands upon the 3rd person starter assets. would it be possible to have the melee combat have animations where you dont just animate the upper body to perform melee attacks? like if you do a melee attack, you wont be able to move until the melee animation has finished playing like in most action games? a combo and targeting system would also be nice :)
Yes please! Would love this!
@@nooksniche lessssssss ho
Yeeeee
Yes please!
If anyone is having difficulty aiming and walking at the same time, you need to create an Avatar Mask. Open up "Humanoid" in the Avatar Mask and deselect the legs and lower IK so that only the upperbody is green. Then, click the cog wheel on the Aiming layer and add the Avatar Mask to the Mask field. This will make it so that when aiming, only the upper body bones are affected and you will still be able to walk as per the Base Layer animations.
Great point, In addition to this,
make sure you set your model to humanoid.
After you import your fbx file, under the inspector, select "Rig" and then choose "Humanoid" under the animation type.
This will allow you to switch layers and also prevent the bug of (the character from showing halfway through the ground).
Is the avatar mask created from the aiming animation fbx?
@@noblephantasms7250 You can do this by Right Clicking Create go down to Avatar Mask.
From there I clicked on the legs, body and the bottom 1ks.
Then on your Animator and your Aming Layer, click the gear icon, add the mask you just made and click on IK pass.... This is what I did any way works for me :)
For people who don't know how to do it ua-cam.com/video/W0eRZGS6dhQ/v-deo.html
@@pawepatrzek2785 thanks for the reply although I just finished University last month
for those stuck between 20:00-23:00:
1. make sure the BulletProjectile script is on the pfBulletProjectile prefab (click the prefab and drag the script on).
2. Also, click on the prefab and make sure Use Gravity is ticked off.
Still following the tutorial, but was stuck for a good while on this. Good luck!
update: works perfectly thank you so much this is an amazing tutorial
I have been stuck on this for an hour, thank you so much!
Thank you I was wondering why my bullet would spawn and just hover took me hours and reading this comment fixed it thanks!
Thank you!!! I spent 2 hours looking around and not understanding why it's not working lol
You're a life saver!
@@irisshard2336 ikr! lol, I'm very happy now!
Thank you so much!
There is a legend that someday CodeMonkey Sensei will explain how to work with the animation Rigging Package ...
Brackeys made a tutorial on animation rigging, you should check it out
@@Fizz17 Yes I found somebody videos but I love Code Monkey videos Tutorials. He is ver clear and I can Understand all that he show...
You can also check kiwi coder he is doing a series using animation rigging
Yes, this is the way
SOOOO first go-round I broke everything at 7:00 into the video. My error was that Code Monkey quickly attaches the script for toggling between the zoom and normal camera that I missed that he had attached the PlayerAimContorller script to the PlayerAmature rather than the PlayerAimCamera. I have about a weeks worth or Unity so for anyone else that hits this error hope this helps.
Had same error dude
Third person shooter controller?
I know how to fix it... just open your thirdpersonshooter script and change private void"awake" and "update" to "Awake" and "Update". (capital letters)
i know im late to the party and i might have missed it but i did also have about 100 errors rolling in a minute when i had hit play to test out the zoom, what fixed it for me is under PlayerArmature, the ThirdPersonShooterController script, i dragged the PlayerAimCamera into the Aim Virtual Camera, and the errors went away and is working as it should be. hopefully that helps anyone out that might be having that issue or overlooking something potentially simple.
@@davisardians8411 thanks so much it worked
Another great tutorial, thanks a lot! Also I think I found a neat solution for aiming in the sky (14:02), without needing boundary colliders everywhere. If the raycast returns false move to an else block and create the aiming point by projecting a vector in the direction of the camera orientation, from the camera position, at a desired distance from it. For example I set mine to 200:
if (Physics.Raycast(ray, out RaycastHit raycastHit, 200f, AimColliderLayerMask))
{
DebugTransform.position = raycastHit.point;
}
else
{
DebugTransform.position = _cam.transform.position + _cam.transform.forward * 200f;
}
Let me know if I am overseeing something and there is a problem with this, but thanks again for the video.
Yup that's an excellent approach, that's what I would do if I used this controller in a full game instead of just a simple demo.
hey can you tell me like _cam is what what ihave to give refrence of here
@@alovelygondal7673 Hi, this is in relation to the main camera. if you want you can use this instead which will work as long as you have one main camera.
else
{
debugTransform.position = Camera.main.transform.position + Camera.main.transform.forward * 999f;
}
This is the first tutorial I found showing how to extend the Unity Starter controller up to a real use case scenario. Great content, thank you!
For bullet not working, :
- Add the bullet script to your bullet => he not showed it but it said it (i realised that after 10x watching haha)
- Make your bullet a prefab, drag and drop it in the prefab folder. Than delete it from the scene, and drag and drop the prefab in "Bullet Projectil" from thirdPersonShooterController on the playerArmature
- If it bounce/not destroy; make the colider a few bigger than the cube
Wow I was stuck on that for so long! Thank you!
Thank you brother! These comments are gold for unity noobs that miss these subtle things and get stuck and on the verge of saying fuck this.
@@DeKosta Literally was me a second before I found this haha
Not all heroes wear capes
Thank u Bro
For the hit scan on 27:08 if the particle shows up on the feet it is because it is using the player transform position.
Make a var called like hitpoint, similiar to the debugTransform, in the 'raycast IF statement' set the new var hitpoint to the 'raycastHit.point', and in the shoot instantiate code replace transform.position to the hitpoint variable.
Thanks for the tutorial, learned alot!
ty dude =D
Was having trouble with this, thank you. You can also just replace transform.position with debugTransform.position in that if statement.
thanks bro I'm about to rage quit lol glad i check the comment section
How ? replace ? I need help
Thank u bro
What a quality channel! Thanks for video.
Also for the crosshair if anyone wants an easy way to enable it when aiming and disable when not you can add
[SerializeField] private GameObject crosshair; // makes a serialized field for the image of the crosshair to be assigned to.
In Awake: crosshair.SetActive(false); // hides the crosshair to make sure it is hidden at the start.
In Update
if (starterAssetsInputs.aim) // if the user is aiming
{
crosshair.SetActive(true); // set crosshair to enabled.
}
else // if they are not aiming
{
crosshair.SetActive(false); // disable the crosshair
}
Then in Unity drag the crosshair image onto the serialized field.
Hope this helps anyone who wants this easily.
The full code up to the crosshair section for me is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
using StarterAssets;
public class ThirdPersonShooterController : MonoBehaviour
{
[SerializeField] private CinemachineVirtualCamera aimVirtualCamera;
[SerializeField] private float normalSensitivity;
[SerializeField] private float aimSensitivity;
[SerializeField] private GameObject crosshair;
private StarterAssetsInputs starterAssetsInputs;
private ThirdPersonController thirdPersonController;
private void Awake()
{
starterAssetsInputs = GetComponent();
thirdPersonController = GetComponent();
crosshair.SetActive(false);
}
private void Update()
{
if (starterAssetsInputs.aim)
{
aimVirtualCamera.gameObject.SetActive(true);
thirdPersonController.SetSensitivity(aimSensitivity);
crosshair.SetActive(true);
}
else
{
aimVirtualCamera.gameObject.SetActive(false);
thirdPersonController.SetSensitivity(normalSensitivity);
crosshair.SetActive(false);
}
}
}
Hey thanks it worked. It took a few tries because I'm not a coder and was far ahead by the time I found this comment
is there any way that this virtual camera only follows characters back and on look input its works same before ...if character rotate than the virtual camera shoul have to rotate as to follow charcters back
7:00 This is not working, aim camera can't appears with input.
if this not work correctly:
Vector3 worldAimTarget = mouseWorldPosition;
worldAimTarget.y = transform.position.y;
Vector3 aimDirection = (worldAimTarget - transform.position).normalized;
transform.forward = Vector3.Lerp(transform.forward, aimDirection, Time.deltaTime * 20f);
Just use this:
transform.rotation = Quaternion.Euler(0, Camera.main.transform.eulerAngles.y, 0);
The instantiating bullet can be used in a realistic game as then we can set the spawn point in the guns barrel and then if this happens( 27:54 ) then it shows that the bullet actually spawns from the guns itself and not from the middle of the screen, many realistic FPS/TPS games do this thing and it adds that extra bit of realism to the game really cool, raycast can be used for a more arcade shooter
21:41 bullets are spawning but hey are not moving towards to forward. what can be the problem?
I saw an error: @ around 27:20, near the ending of the Raycast shooting tutorial, the Instantiate methods are spawning the particles at transform.position, aka the player position.
This makes the particles spawn inside the player.
It should be changed to mouseWorldPosition or debugTransform.position which is the raycast.point value of where the raycast hit.
Oh yeah nice catch, yup it should be the mouseWorldPosition, seems I cut the video where I fixed it
Its funny when you do it because it looks like the character is exploding! Could you maybe add or explain the steps to get the Pistol Idle animation from Mixamo? I can only download the entire mesh, I dont know how to extract the .animation file from the .fbx
@@chrheca Click on the arrow icon to expand the object, inside is the animation, click on it then Ctrl + D to duplicate and it will duplicate it outside of the .fbx as a separate asset
@@CodeMonkeyUnity Something is missing the animation isn't playing and on preview it is a T mode animation
Thank you, I spent like an hour trying to find my mistake haha
If you want the crosshair to only appear when you right click (like in a non-shooter focused game with shooting mechanics) then make a new script with this:
using UnityEngine;
using System.Collections;
public class Cross : MonoBehaviour
{
// Graphic used for crosshair
public Texture2D crosshairTex;
// Rect for crosshair size and position
private Rect crosshairRect;
// bool to turn crosshair on and off
public bool IsCrosshairVisible = true;
void Awake()
{
Cursor.visible = false;
crosshairRect = new Rect((Screen.width - crosshairTex.width) / 2,
(Screen.height - crosshairTex.height) / 2,
crosshairTex.width,
crosshairTex.height);
}
void Update()
{
if (Input.GetMouseButtonDown(1))
{
IsCrosshairVisible = !IsCrosshairVisible;
}
if (IsCrosshairVisible == true)
{
IsCrosshairVisible = true;
}
else
{
IsCrosshairVisible = false;
}
}
void OnGUI()
{ // draw the crosshair in center of screen
if (IsCrosshairVisible)
GUI.DrawTexture(crosshairRect, crosshairTex);
}
}
@@CDisplay-o9t Or just:
void Update() {
IsCrosshairVisible = Input.GetMouseButtonDown(1);
}
😱😱😱
@@CDisplay-o9t that works. I actually used this line of code(input.getmousebutton down and up) to make the aiming instead of using the new input system. Works well for me!
Thanks for the tutorial. It really helped me to move forward my project. Here is a tip:-
Instead of placing cubes around the environment for player. just get a point from ray at a distance.
Ray ray = _cam.ScreenPointToRay(screenCentrePoint);
debugTransform.position = ray.GetPoint(20);
GetPoint will give you at point on the ray at the distance you have given. so even if player is aiming at the sky it will work without placing collider around environment.
Vector2 screenCenterPoint = new Vector2(Screen.width / 2f, Screen.height / 2f);
Ray ray = Camera.main.ScreenPointToRay(screenCenterPoint);
if (Physics.Raycast(ray, out RaycastHit raycastHit, 999f, aimColliderLayerMak)) {
debugTransform.position = raycastHit.point; }
else
{
debugTransform.position = ray.GetPoint(20f);
}
Like this right?
Damn bro, I was about to ask if there was a way to fix that, and there you go saving the day. Thanks mate!
If anyone is a fool like me, make sure you also set the moustWorldPosition = to the ray.Getpoint() otherwise when you aim at the sky your not getting that variable updated.
Yes, this is exactly the solution I was looking for. Thank you.
Edit:
This does fix the abrupt change of aim when going from one target to another, but the aim is no longer accurate. I think I'll have to find a way to smooth out that abrupt change.
____________________________________________________
Great idea, thanks. Additionally, I would say that when you're aiming at objects other than sky, still better to use debugTransform.position = ray.GetPoint(20); because in this way your aiming will stay smooth. If debugTransform keeps jumping from object to another, your character's aim abruptly changes, which in my opinion is not desirable (at least for my game design):
Here's the code :
Vector3 mouseWorldPosition = Vector3.zero;
Vector2 screenCenterPoint = new Vector2(Screen.width / 2f, Screen.height / 2f);
Ray ray = Camera.main.ScreenPointToRay(screenCenterPoint);
if (Physics.Raycast(ray, out RaycastHit raycastHit, 999f, aimColliderLayerMask))
{
debugTransform.position = ray.GetPoint(20f);
mouseWorldPosition = ray.GetPoint(20f);
}
else
{
debugTransform.position = ray.GetPoint(20f);
mouseWorldPosition = ray.GetPoint(20f);
}
I will say brackeys MADE ME QUIT UNITY 3 TIMES why his scripts never worked for me.
When you turn the character to the direction you're aiming, you use Lerp with the current position in the first argument. Lerp really works when you continually provide the original starting value and a final value on every frame. If you don't want to keep track of the original starting value, use MoveToward or RotateToward instead. The progression of values you get with Lerp are only linear if you use it as designed, with the original starting value on every call.
Yes I intentionally do not want it to be linear. I want it to be faster the further away it is from the target so it gets there faster.
Can someone help me i am stuck at this error : my player doesn't shoots whenever i try to shoot this error pops up: MissingReferenceException: The object of type 'Transform' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, UnityEngine.Vector3 pos, UnityEngine.Quaternion rot) (at :0)
You should do a tutorial on a First Person Controller setup with full body awareness and animation rigging. I just realized while putting mine together that there are no real good tutorials for that out there for reference so I had to do mine all by scratch. It was actually more tricky than I expected. I never realized things like keeping the head and body separate for networking reasons. Or how difficult it really is to get the body to perform like an actual body in relation to eye sight and the hands/gun movement.
i love this tutorial and everything was going smoothly until i finished the bulletprojectile script... the bullet would spawn in the scene but it wouldnt have any velocity, it just spawns and stays still. anyone had similar issues? ive rewatched and checked my scripts 20 times, still no fix
Add a Debug.Log where you're setting the velocity, is that line running? Are you maybe setting it to 0,0,0?
Is your script actually attached to the bullet prefab?
@@-pcmr-108i faced the same problem and i tried what you said and that was the error for me idk how i did missed that but thank you !.
Bro facing the same problem.
Bro i just fixed it what was the mistake is that in I forgot to writeline that was
mouseWorldPosition = raycastHit.point;
in ThirdPersonShooter Script in :
if (Physics.Raycast(ray, out RaycastHit raycastHit, 999f, aimColliderLayerMask))
you also check it as his video is so fast that I didn't even noticed even after watching 10 times
I've been searching online for a true first person shooter controller Tutorial and found nun if you could make one that would be amazing for those of you who don't know what a true FPS is it's like a third person controller it uses third person animations and a full body but the camera is mounted on the head games like escape from tarkov and arma 3 use it
BULLET WON'T MOVE:
You need to add the BulletProjectile c# script to the BulletProjectile prefab! (not shown in the video)
Which pack did you use for the gun animations for the final demo?
Great walkthrough CM. I was wondering if you experienced problems with the mixamo weapon related anims. Im experiencing a problem with ALL the weapon/aim anims from mixamo when applying the 'aim' animation layer mask weight to 1. Before applying the weight the character is facing straight forward in the idle animation like normal but when i make the weight 1 and activate the aim anim the character does not aim straight forward but to the left. So he goes from facing north to facing north west when the animation layer mask is applied. When setting up animation rigging to correct this the character just falls halfway into the ground and doesnt perform the idle animation but instead is just frozen in a weird pose.
I haven't encountered that issue but if you select the FBX file you downloaded and look in the inspector import animation settings you can change lots of things including applying a rotation offset
@@CodeMonkeyUnity You truly deserve more love! Thank you 🙏
@@wn9521 Could you pls explain to me what you have done to fix this problem?
@@Luffius I had this same problem, if you go to the inspector for the animation, then go to animation window and go down to motion you can set it to the joints of the PlayerArmature or whatever you want it to rotate towards at the start of the animation. This is using the root motion node.
Bit late for an answer but if you select the animation taken from Mixamo once imported select Animation tab then scroll down to Root Transform Rotation and set it from Body orientation to original that should sort the aiming offset out.
Everything is same but aim isn't working...
i have solve the problem: just make the Priority of both Virtual Camera same.
I'm having this weird issue where after I complete the work from the aim input section my camera starts moving weirdly, it starts teleporting instead of smoothly moving on screen.
same here
I had the same issue. I tried EVERY fix I could Google. What finally "fixed it" for me was just closing Unity, playing Rocket League for a little bit and then coming back to it. I don't know what the **** happened in between but restarting Unity and going right back in, did NOT work. But coming back an hour later did? I have no idea. Its the second time I've come across this issue and the second time that little "turn it off and come back later" fix worked.
I know its not exactly a solution but, that did it for me so I figured I'd share.
Still having this issue. Anyone found a solid way to fix this?
So this worked for me. I selected the PlayerArmature in the Hierarchy then in the Inspector I expanded the PlayerInput component and then clicked on Open Input Settings button. In the settings window I changed the Update Mode to Process Events in Dynamic Mode and that fixed it for me. Not sure about the trade offs of selecting this Update Mode though.
How to Add Jump in Low Poly Shooter Pack - Free Sample v 2.0
This is perfect, I'm currently working on and trying to learn how to make some good feeling Third person shooter controls!
if you have any questions ask me, i spent hours on this tutorial to made it working from 0.
Hi dude at 13:00 when I attach the sphere to the debug transform and play the scene nothing happens the sphere stays where it was placed and it does not follow the camera
tbh the controller from Unity is kinda trash since the jump and everything is basically hard coded, if you want to do something like removing the player control after jumping you basically have to rewrite everything
I like using FSMs. Tried this for the first time after writing different controllers bc it takes a long time to get everything nice and polished. Immediately hated it. I cant come up with game ideas anyway, so I'll just keep working on third person character controllers
Please add simple climbing and ledge hanging. Thanks great series.
Hello code monkey i am facing a problem in my unity editor.There is a compiler error from a script that i didn't create and i don't know how to fix the error and when I open my asset in package manager it shows a error and then crashes i am using unity 2020.3.3 please tell me how to fix these problems i am just a 12 year old boy and i really need unity to create a game
Well first you need to know exactly what the error is
If it-s related to a external package try reinstalling that one
33:21 This part does interest me a lot since it's one of the things I've had issues with for upper body aiming. I tried IK but it didn't quite work out as I wanted.
Select Rig, Change Avatar Definiton to "Copy From Other Avatar", and select Armature Avatar as source
@@zexanein Thank you, I was struggling with this all day!
hello code monkey!! great tutorial but it seems like im stuck at 17:00 my character somehow doesnt face in the aimed direction but instead he turns away from it....idk what i could've done wrong and need ur guidance to solve this issue....
Does the walking rotate correctly? Only the aim has issues? Pause the game and look at the character, is the transform rotated? Or the animation?
Look in the animation import settings and make sure it's not rotated by default, you can bake a rotation override
Excellent tutorial! I had already got a basic combat system going with the Third Person Controller, but I was not at all happy with the camera. This tutorial made it all right as rain, thank you! :)
i did it exactly like you and its
choppy while looking around
Can you make a video on how you polished everything at the end? Because I have the animations and functionality down, but it would be very helpful if there was a video showing how to add for example a walking animation while aiming, all the FX used and so on.
Other than that this video was great and really helpful :)
I'm planning on doing a video on animation rigging which is what I used to make the weapon aim at the target
For walking while aiming, that's just adding a Avatar mask on the second layer and only overriding the upper body, leaving the legs to walk
@@CodeMonkeyUnity Hey Code Monkey! What if I want incorporate a different movement animation while aiming? How does that work? Can you please make a video on that one or could you briefly explain it?
@@CodeMonkeyUnity ahhhhh see that's good so instead of doing it through code, animation rigging makes that much simpler, nice!
@@rickyreaves5794 I have since made that video on how the Aim Animation Rigging works unitycodemonkey.com/video.php?v=luBBz5oeR4Q
Hey code monkey 🙂 can you please make tutorial of how to make cover system
I have waited so long for this, thank you Mr. Monkey
How could we make it so the player cannot sprint if they are aiming?
The isAiming is a bool so just check if that is true don't enable sprinting
This! This is what I needed to know to make the game I had in my head for almost a year, but put it to the side for easier challenges
HI Where would you attach the bullet projectile script? Thanks
You just attach it to the pfBulletProjectle prefab!
I absolutely love this video. Right up to the point of adding a point animation. I can't find anything easy to follow that will allow me to add animations to the standard unity third person controller.
I figured this issue out for anyone else that might come across the same problem. I did this - Go to the "Rig -> Animation Type" and change from "Generic" to "Humanoid" and click on "Apply". That fixed it.
When i finish until 28:00 I have two problems: when we use the logic without the projectile the particle does not apear and with the projectile when I shoot at least 10 bullets thew system says that the transform has been destroyed and I cannot call the variable INSTANTIATE! what could be
Thanks for the tutorial. But I have a question in the Animation section. I followed the steps like you showed at 29:20 and gave the "Aiming" layer a weight of 1 but for me it still is in the Idle animation of Base Layer. I can see that the Pistol Idle animation is playing as that blue line of progress runs on that state, but in the Game window, the character doesn't actually follow that animation but rather is still in the base layer idle animation. Any ideas as to what could be the issue here? Thanks.
Did you maybe assign a mask with nothing selected? Does the aim animation work correctly by itself?
@@CodeMonkeyUnity I replied a follow-up after a couple of days, but it's gone for some reason. Thanks for the prompt response from your side.
Anyway, figured this issue out for anyone else that might come across the same problem. I did this - Go to the "Rig -> Animation Type" and change from "Generic" to "Humanoid" and click on "Apply". That fixed it.
I had the exact same issue and BAM, there's your comment... thank god I didn't stop scrolling :) Thanks Santosh and CodeMonkey!
@@Santosh-tq4nj hey need help in this can you please explain these steps in detail as i am new to unity
@@darshankhaire879 have you managed to solve it?
where did you get those gunshot sound effects?
if you feel that the camera lags when you move the mouse, you can try this solution found on Unity forum :
2021.2.7 uses version 1.2 of the Input system package which has an issue with inputs delta when set to fixed update and can cause the lags you are seeing.
To check if that's the issue you could try this:
Edit -> project settings -> Input system package
If Update Mode is set to Process events in fixed update change it to Process events in dynamic update
I hope this will help you and thank's for this tutorial :)
Thanks a lot!
This fixed the camera lag i had!
Thank you
can't wait for the Code Monkey's 3D TPS game in the future
Great little tutorial. I liked the new input system you are using compared to the old one. The coding you added for the third person controller was also pretty informative. Gotta save this to use later if I get around to doing a tps shooter demo in the future.
why don't we use object pooling system for bullets?
You can
Honestly this is awesome. Doing this except for a melee system would also be awesome, to cover both melee/ranged weapon systems.
Pls when i play the project, i can zoom but i can't zoom disable
Sounds like you're not listening to the button release
Please make a assest of this 😭😭
Code Monkey, you have outdone yourself. This is so fantastic. It also provides a great framework to expand upon. Thanks so much for providing so much learning for no cost to the viewer! Youre doing the community such a wonderful service. We are all so very grateful for your time and hard work helping all the little guys and gals out there trying to get better! Thanks!
I'm glad you liked the video! Thanks!
@@CodeMonkeyUnity Great video. Could you tell us anything about the post processing you have set up? Is that just the demo scene in URP or are you using custom PP? I ask because I'm using HDRP and my demo scene doesn't look anywhere as nice as yours. Thanks for the great content. Liked and subscribed :D
@@JimmyThe It's just Bloom, a bit of Saturation and a Vignette effect
Hi ! Thanks for the tutorial but I have a problem at 24:00. My projectiles, instead of going straight into where my mouse is like in the video, they fall directly to the ground when I press my button to shoot. Do you have a way to resolve this? Thanks and I'll stay tuned
Sounds like you did not disable gravity and did not assign the Velocity field
Hi ! Thanks for your response. Please, How Can I do this ?@@CodeMonkeyUnity
Hi I found out for the gravity but not for the gravity field@@CodeMonkeyUnity
Are you millionaire?
I was going to make a system based off of the video "How to make ALL kinds of GUNS with just ONE script! (Unity3d tutorial)" by Dave / GameDevelopment @davegamedevelopment but it is done in the Input.GetKeyDown system, how can change that system to use it on the unity starter assests input. Could you make a video like the video I showed but for the new system because I really want the stats to be easily changeable, as there will be many guns in my game. Thanks!
I just wanna point out this guy still answering questions in more than a 1 year video. True Legend!!!
in 18:40, I want my character to be constantly fasing the way I'm looking and don't have an aim function. So I just used the code out of if statement and still works great! My only problem is, because player is actually looking to raycasted object, for example if I push my right shoulder to the wall and look at the wall, because of the perspective, object actually moves behind the character and causes to player to actually look back. Is there a possible way that I can fix this?
Heh yup as long as someone posts a comment on the video an not on a reply I'll probably see it the next day.
For that issue the best solution is to look at how far the target object is, if it's too close then don't look at it. Either lower the rig weight or define a point a certain distance in front
@@CodeMonkeyUnity Thank you so much for the reply I'll give it a try. Another problem is, I'm running all this on Netcode. Because I don't want other players to shoot for myself, I put my aim point and muzzle point in my player prefab, and then made them separate prefabs so I can reach from transform function. Right now my bullets spawn, but doesn't spawn in my muzzle point, instead spawn at 0,0,0 and doesn't move. What should I do?
Show us please that how you work with animaction rigging pakages like in this project
Hello Code Monkey, its a update on the asset pack and when I was going to multiply the Camera Rotation it says //Don't multiply mouse input by Time.deltaTime; And instead of Time.DeltaTime it says deltaTimeMultiplier. Please Help.
thank for the video! it was super useful, but where you learned about the animation rigging package? any video?, thank btw
I read the manual and played around with the samples.
I've actually got a video on that package coming out this weekend so stay tuned!
@CodeMonkeyUnity can you help me in how to fix the error "The type or namespace name 'cinemachinecamera' could not be found (are you missing a using directive or an assembly reference?" what should I do
You're missing "using Cinemachine;" on thh top of the file, that's the namespace that contains the CinemachineVirtualCamera type
@@CodeMonkeyUnity Now i am stuck in place where it says cannot convert from 'UnityEngine.Transform' to 'UnityEngine.Vector3
Make more tutotials about shooter game please
14:26 A more simple solution
if(Physics.Raycast(ray, out RaycastHit raycastHit, 999f, aimColliderLayerMask))
{
debugTransform.position = outhit.point;
}
else
{
debugTransform.position = ray.GetPoint(30);
}
When there isn't a collider in front of the player, the target point will be a little bit away from him if you write this code.
why it is 30f?
all your videos are good.... But this is best :)
when I change the sensitivity from the ThirdPersonShooterController the sensitivity does not change
where should I put the bulletProjectileRaycast for the polished game part?
hey i would really appreciate if you made a tutorial for sword and shield third person attacks love your content hope you see this😉
I can't even change the values of transform properties
How so? What transform? From where are you trying to change?
when importing the pistol idle animation I downloaded from mixamo and putting it on a separate layer it doesn't do anything even after changing the weight to 1, anyone else come across this and worked out what it might be?
Sorry for my bad english but if u can shoot u need to swap bullet scrip in pfbulletprojectile
can anyone help me with this error? error CS1519: Invalid token ';' in class, record, struct, or interface member declaration. At the end of [SerializeField] private float Transform debugTransform;
You defined 2 types, float and Transform
A field can only have one type
could you help me when I'm turned on my back and aim forward my character the x axis moves that is it does a somersault when I look at the sky could you help me thank you
I just Imported the Assets and everything is Pink for some reason. I just don't understand how to fix this are the assets broken now or is something wrong with my unity version? How do I fix this? Please reply as soon as possible. Btw love your videos!
Pink means shader error, which likely means your project is set up to use the Built-in Render Pipeline instead of the Universal Render Pipeline
@@CodeMonkeyUnity My PfBulletProjectile is not moving forward it just stays at a place
@@CodeMonkeyUnity MissingReferenceException: The object of type 'Transform' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, UnityEngine.Vector3 pos, UnityEngine.Quaternion rot) (at :0)
Awesome video! Would love to see/purchase a full (or more expansive) third person shooter (or FPS) tutorial from you ^^
i dont have the vfx in this video,how can i gei it?
You can just make it yourself, it's just a simple particle effect
Can u tell me how to add gun model and firing animation??
Hey @CodeMonkey Bhai mai ik game bana raha hu , so i want that can you make a detailed video on "Infinite Procedural terrain generation" and " How to make animation of NPC's Like GTA-6 "that they are interracting with temselves like a real human . In terial is See that the NPC's are passing WaterBottels And Playing Basketball . And Like I give an example If The Frankline Goes To A Rich Colthing Shop the Owner Call The Police But Don't call Police When tere is another Game Character And Like If In Eveing You Comes Near To Girl It calls Police and Police Caught You Like That . Please make video on it .
This is Great I have purchased the Space Combat kit from unity and I would like to implement my character with this into it. It would be awesome if you can do a tutorial on the space combat kit and implementation of this.
Thanks for 106 subscribers completed ❤🎉
Hi @codemonkey newbie here, I have been trying to modify the movement script so that when the player presses A or D, the character doesn't rotate, instead, the character just moves to the side without rotating, so, aiming to the front all the time but still moving to the side, like a strafe motion. But I have failed. Would you please give me a hand?
the following is not working correctly for me. I don't know why it worked in the video.
lo siguiente no me funciona correctamente. No sé por qué funcionó en el video.
if (hitTransform != null)
{
if (hitTransform.GetComponent() != null)
{
Instantiate(vfxHitGreen, transform.position, Quaternion.identity);
}
else
{
Instantiate(vfxHitRed, transform.position, Quaternion.identity);
}
}
pero lo reemplace por
if (hitTransform != null)
{
if (hitTransform.GetComponent() != null)
{
Instantiate(vfxHitGreen, mouseWorldPosition, Quaternion.identity);
}
else
{
Instantiate(vfxHitRed, mouseWorldPosition, Quaternion.identity);
}
}
what do you mean by that!!!
(I'm seeing errors related to LWRP or Light2D?
Some projects were made before Unity renamed LWRP into URP so they contain the old namespaces, just change them into the Universal namespaces and everything should work.)
If you see errors on the usings change from using UnityEngine.Experimental.LWRP to UnityEngine.Rendering.Universal
Look up the URP docs
@@CodeMonkeyUnity Thanks!!!
@@CodeMonkeyUnity what does that eror mean?( 'PlayerArmature' Animation Event 'OnLand' on Animation 'Walk_N_Land' has no reciver! Are you missing a component? )please i cant move
Hello Code Monkey and everyone, can you guys give me some solutions about why do the bullets i fired falls down to the floor instead go straight to the target crosshair? I have followed all the tutorial in this video from 19:31 to 24:00 and still can't figure out what i missed. Every answer you guys give will mean a lot to me. Thank you before.
Disable gravity on the bullet.
Add some Debug.Log to make sure you're setting the velocity correctly.
And make sure you're not spawning inside the player collider, or make sure there's no collider right in front of the spawn position.
@@CodeMonkeyUnity Actually i forgot to insert the Bullet Projectile script into the pfBulletProjectile because i didn't see it in the video. After adding the script, everything goes well. Thank you for answering. I'm looking for you another great tutorial.
@@magusmagustav had similar problem, we need to attach the script to the prefab and not the parent empty
object of prefab
@@hireshtrivedi9731 Thanks mate!
help getting this error 'CinemachineVirtualCamera' does not contain a definition for 'gameobject' and no accessible extension method 'gameobject' accepting a first argument of type 'CinemachineVirtualCamera' could be found (are you missing a using directive or an assembly reference?)
It's gameObject not gameobject
What about picking up a gun and only letting it shoot when its picked up?
Use a collision to test if you have touched the weapon to pick it up ua-cam.com/video/Bc9lmHjqLZc/v-deo.html
Then you could toggle a simple bool to allow the player to use that weapon
@@CodeMonkeyUnity Thanks!
What is the best way to expand this controller: to add your code inside the existing script or attach another script to an object and add more logic there?
Depends on what you want to add to it, if its adding some other feature like Auto Aim, I would make it in the same script, if its adding a complex weapon manager logic, I would make a separate script
@@CodeMonkeyUnity thanks for the prompt reply! I was thinking about adding more actions and animation handlings, like melee fight, taunts/gestures.
Hey code monkey. Can’t you just do cam.position.forward. 12:25
How to create Character Controller swimming on Water surface and underwater Character Controller doesn't Support Rigid body and gravity I don't know how to Create swimming please reply me Sir
Love the content, but could you slow down some. You type at full speed and then scroll as soon as your done to the next spot. Very hard to follow along without pausing and rewinding every few seconds.
I love video, its super helpful! Question tho, at 15:15 you have the debugTransform sphere slowly approaching the armature, but at 15:16 it jump cuts and this issue no longer happens. How did you stop the debug sphere from moving toward player, I'm having this issue and don't know how to fix it?
Remove the collider on the sphere. The issue is the raycast hits that collider which means the next position is a tiny bit closer, then it hits again and so on and on
@@CodeMonkeyUnity THANK YOU! I would have never been able to deduce that, I cant believe its that simple. Thanks for teaching me the reason "why" for this behavior as well. Ive learned a lot from you :)
When I aim(or don't) and try to rotate, the camera won't budge, and if I move while I aim, it will end up where the player faces the camera.
Hey,
I have a doubt. We can't use your project files for commercial purposes, right? As they are part of the Synty battle royal pack and to use your project files commercially, we would need to get that pack right? If yes then it will be nice if you mention this in your video so that everyone is aware of this.
The project files don't include the visual assets, you can use the project files in your own games, everything there was made by me
Finally video launch lovely video
I can see a bit of a flaw in the execution here, what happens if you stand directly to the left of a pillar? The camera & crosshair will be in front of the pillar, and your bullet will fire backwards. I'm not sure what the best solution would be though, perhaps offsetting the starting position of the raycast forwards to the minimum distance in front of the character/camera that you want them to be able to shoot?