JonDevTutorials
JonDevTutorials
  • 5
  • 193 846
ADD ARMS TO YOUR GAME - EASIEST WAY (Unity3D)
Thanks for all the nice comments on my other videos.
If you enjoyed, don't forget to like and subscribe.
Sorry if this video is a bit scuffed, it's long because there isn't any code I can tell you to copy paste and I have to show you every step. Plus I'm too lazy to edit it down to 12 minutes.
Переглядів: 70 695

Відео

VAULTING/CLIMB LEDGES UNITY TUTORIAL (FPS)
Переглядів 20 тис.2 роки тому
This is truly one of the unity tutorials of all time. Simple way of adding arms coming soon (within a week) GITHUB: github.com/JonDevTutorial/LedgeClimbingTut
Random AI Patrolling Tutorial Unity3D
Переглядів 63 тис.2 роки тому
In this video I will teach you how to make a navmesh agent move around randomly within an area. Code (yes you can use it for whatever you want): github.com/JonDevTutorial/RandomNavMeshMovement
How to Pick Up + Hold Objects in Unity (FPS)
Переглядів 37 тис.2 роки тому
In this video I show how to pick up, rotate, and throw objects in Unity. CODE (YES YOU HAVE PERMISSION TO USE IT): github.com/JonDevTutorial/PickUpTutorial
How To Set Up A Mixamo Character In Unity
Переглядів 3 тис.2 роки тому
Other Unity tutorials are too long, here is a short one.

КОМЕНТАРІ

  • @WebbyTheGoat
    @WebbyTheGoat 9 днів тому

    the ai is falling through the floor

  • @charljustinedarapisa6758
    @charljustinedarapisa6758 10 днів тому

    Can I use this function to make a random wildfire behaviour? Thank you.

  • @AaronRiggs-b5e
    @AaronRiggs-b5e 18 днів тому

    This was the best dev video I have ever seen lol short to the point and hilarious. THANK YOU JonDevTutorials!

  • @lityumLi
    @lityumLi 18 днів тому

    which unity version did you used in this tutorial

  • @CobusGreyling
    @CobusGreyling 19 днів тому

    "Here it is visualized" LMAO

  • @ODDV69
    @ODDV69 26 днів тому

    when i move the hands do not go with the gun i did everything like the video

  • @teste-x6o
    @teste-x6o 27 днів тому

    Great work, thanks for explain how to rotate an object! For those in the future, i did it this way: using System.Collections; using System.Collections.Generic; using UnityEngine; public class Interactor : MonoBehaviour { public GameObject player; public Transform holdPosition; //if you copy from below this point, you are legally required to like the video public float throwForce = 500f; //force at which the object is thrown at public float pickUpRange = 5f; //how far the player can pickup the object from private float rotationSensitivity = 1f; //how fast/slow the object is rotated in relation to mouse movement private GameObject heldObj; //object which we pick up private Rigidbody heldObjRb; //rigidbody of object we pick up private bool canDrop = true; //this is needed so we don't throw/drop object when rotating the object private int LayerNumber; //layer index private PlayerMovement playerMovement; //Reference to script which includes mouse movement of player (looking around) //we want to disable the player looking around when rotating the object //example below //MouseLookScript mouseLookScript; void Start() { LayerNumber = LayerMask.NameToLayer("holdLayer"); //if your holdLayer is named differently make sure to change this "" playerMovement = player.GetComponent<PlayerMovement>(); //mouseLookScript = player.GetComponent<MouseLookScript>(); } void Update() { if (Input.GetKeyDown(KeyCode.E)) //change E to whichever key you want to press to pick up { if (heldObj == null) //if currently not holding anything { //perform raycast to check if player is looking at object within pickuprange RaycastHit hit; if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, pickUpRange)) { //make sure pickup tag is attached if (hit.transform.gameObject.tag == "canPickUp") { //pass in object hit into the PickUpObject function PickUpObject(hit.transform.gameObject); } } } else { if(canDrop == true) { StopClipping(); //prevents object from clipping through walls DropObject(); } } } if (heldObj != null) //if player is holding object { MoveObject(); //keep object position at holdPosition RotateObject(); if (Input.GetKeyDown(KeyCode.Mouse0) && canDrop == true) //Mous0 (leftclick) is used to throw, change this if you want another button to be used) { StopClipping(); ThrowObject(); } } } void PickUpObject(GameObject pickUpObj) { if (pickUpObj.GetComponent<Rigidbody>()) //make sure the object has a RigidBody { heldObj = pickUpObj; //assign heldObj to the object that was hit by the raycast (no longer == null) heldObjRb = pickUpObj.GetComponent<Rigidbody>(); //assign Rigidbody heldObjRb.isKinematic = true; heldObjRb.transform.parent = holdPosition.transform; //parent object to holdpositionition heldObj.layer = LayerNumber; //change the object layer to the holdLayer //make sure object doesnt collide with player, it can cause weird bugs Physics.IgnoreCollision(heldObj.GetComponent<Collider>(), player.GetComponent<Collider>(), true); } } void DropObject() { //re-enable collision with player Physics.IgnoreCollision(heldObj.GetComponent<Collider>(), player.GetComponent<Collider>(), false); heldObj.layer = 0; //object assigned back to default layer heldObjRb.isKinematic = false; heldObj.transform.parent = null; //unparent object heldObj = null; //undefine game object } void MoveObject() { //keep object position the same as the holdPositionition position heldObj.transform.position = holdPosition.transform.position; } void RotateObject() { if (Input.GetKey(KeyCode.R)) { canDrop = false; playerMovement.enabled = false; // Desativa o script para bloquear o movimento e olhar float XaxisRotation = Input.GetAxis("Mouse X") * rotationSensitivity; float YaxisRotation = Input.GetAxis("Mouse Y") * rotationSensitivity; heldObj.transform.Rotate(Vector3.down, XaxisRotation, Space.World); heldObj.transform.Rotate(Vector3.right, YaxisRotation, Space.World); } else { playerMovement.enabled = true; // Reativa o script canDrop = true; } } void ThrowObject() { //same as drop function, but add force to object before undefining it Physics.IgnoreCollision(heldObj.GetComponent<Collider>(), player.GetComponent<Collider>(), false); heldObj.layer = 0; heldObjRb.isKinematic = false; heldObj.transform.parent = null; heldObjRb.AddForce(transform.forward * throwForce); heldObj = null; } void StopClipping() //function only called when dropping/throwing { var clipRange = Vector3.Distance(heldObj.transform.position, transform.position); //distance from holdPosition to the camera //have to use RaycastAll as object blocks raycast in center screen //RaycastAll returns array of all colliders hit within the cliprange RaycastHit[] hits; hits = Physics.RaycastAll(transform.position, transform.TransformDirection(Vector3.forward), clipRange); //if the array length is greater than 1, meaning it has hit more than just the object we are carrying if (hits.Length > 1) { //change object position to camera position heldObj.transform.position = transform.position + new Vector3(0f, -0.5f, 0f); //offset slightly downward to stop object dropping above player //if your player is small, change the -0.5f to a smaller number (in magnitude) ie: -0.1f } } }

  • @Romik_123
    @Romik_123 Місяць тому

    YOU ARE MY SAVIOR, LORD, I HAVE SUFFERED SO MUCH, AND HERE YOU ARE, THANK YOU, I WILL DEFINITELY MENTION YOU IN MY GAME!!!!!!!!!!!!

  • @fairplaymaxx7576
    @fairplaymaxx7576 Місяць тому

    WOW I just do the same before watching your video!!- it's still usefull bc i see im not alone.

  • @3bdo7dana93
    @3bdo7dana93 Місяць тому

    when i upload the fbx into unity it got no textures :( tried more then 1 still no textures even tho it got textures in blneder

  • @ohderjonnyX
    @ohderjonnyX Місяць тому

    i guess im late but how can i remove the rotate feature

  • @BlipBlobFishman
    @BlipBlobFishman 2 місяці тому

    "RigLayerLight" is crazy

  • @gamely3
    @gamely3 2 місяці тому

    Is there a way to make it have a certain rotation when you pick it up?

  • @Snow_Crab
    @Snow_Crab 2 місяці тому

    The music really brings me home.

  • @Rattle_me_Bones18
    @Rattle_me_Bones18 2 місяці тому

    every time a pick up an item, another copy is on top of it. how do i get rid of that

  • @portiaselamolela2815
    @portiaselamolela2815 2 місяці тому

    Thanks for help

  • @masoncrowe
    @masoncrowe 2 місяці тому

    dammit, cops just showed up at my door, looks like going to prison 50 year minimum. shouldve liked the damn video

  • @gizmowizard352
    @gizmowizard352 2 місяці тому

    I named my left rig layer RigLayerLight in honor of this tutorial

  • @frog4000
    @frog4000 3 місяці тому

    How can i change R to rotate the object to the Scroll wheel instead?

  • @Edix_32
    @Edix_32 3 місяці тому

    It wont let me pick up the object

  • @Sxcottie
    @Sxcottie 3 місяці тому

    8:50 this was possibly the funniest thing ive seen in a tutorial

    • @4xh9
      @4xh9 Місяць тому

      Before 6 months I saw it and it made me laugh I back now laugh again😂😂

  • @simongiordano5194
    @simongiordano5194 3 місяці тому

    I have a problem, when I take the object and move it to any side, it begins to deform slightly and lengthens or enlarges, how can I solve it?

  • @Sproute-RL
    @Sproute-RL 3 місяці тому

    wow that was very cool

  • @Kingplays342
    @Kingplays342 3 місяці тому

    my enemy aint chasing me when im in its vision

  • @Alphanerd2
    @Alphanerd2 3 місяці тому

    Not gonna like the video just since you said it in here but I will put it on the public playlist I credit my game jam entry to

  • @jimppui1350
    @jimppui1350 3 місяці тому

    Is there any way to include a text which tells what is the button to pick up the object. I have no idea where to put it since the pickup range is after the getkeydown. This would really help!

    • @jondevtutorials4787
      @jondevtutorials4787 3 місяці тому

      Hi! Yes that is definitely possible. You should add a canvas gameobject to the workspace, and add a text object to it. Then you can detect whenever a player mouses over the object you want to pick up by raycasting, checking if it hits the object. If it does hit the object, get it's position and use it to set the position of the text, you will then have to convert the coords from worldspace to screenspace. Then set the text of your canvas object to something like "Press E to pick up". If the raycast is not hitting any pick up objects then make sure the text is set to empty "". So basically all you are doing is placing a UI object in your 3D space, moving it around from object to object and changing the text. Look up some guides on 3D UI elements if you are struggling, best of luck :)

    • @jimppui1350
      @jimppui1350 3 місяці тому

      @@jondevtutorials4787 Im sorry, but can you give me an example for the script since I'm still pretty new to coding.

  • @Ruppertdinglesniffer
    @Ruppertdinglesniffer 3 місяці тому

    how do i drop it

  • @ChiappaRiello-op6zc
    @ChiappaRiello-op6zc 4 місяці тому

    Globox moment

  • @RHYSHALLDIGITALART00122
    @RHYSHALLDIGITALART00122 4 місяці тому

    ive been wrestling with adding animations from blender to unity. unitys import method is dog shit, lining up guns to the hand and not have anything clip is a nightmare. now i can see i can do it all inside unity i can seriously relax!

  • @marvellousdazza2836
    @marvellousdazza2836 4 місяці тому

    What if you have more than one gun? Do you have to use the arms on each gun individually?

  • @Paxmet
    @Paxmet 4 місяці тому

    Dry video, like it!

  • @RsSetayt
    @RsSetayt 4 місяці тому

    I'm working on something similar, but I want to work on an item that can be picked up and dropped off, I don't know how to do that, can you help me?

  • @duhanavc6773
    @duhanavc6773 4 місяці тому

    when I make the same settings in both of my cameras I think my unity only uses one camera and that is the pickupcamera in my unity everything goes black other than the objects in holdlayer. how can I fix it

  • @notuncleben6633
    @notuncleben6633 4 місяці тому

    It worked but when i try on an imported 3d object it still clips through the wall for some reason

  • @mgosnipples6331
    @mgosnipples6331 4 місяці тому

    A complex turn of events, as I am the man in that video, and have since learned from my actions and have liked the video before copy pasting your code. To further extend myself from my past transgressions I have also subscribed to show the courts and society that I am a better man

  • @WorksBones
    @WorksBones 4 місяці тому

    WHEN I PRESS E THE CUBE DISSAPEARS AND YES I PUT RIGIDBODY IN IT PLEASE HELP!!!

    • @ub3rfr3nzy94
      @ub3rfr3nzy94 4 місяці тому

      your pickupcamera isnt set to overlay

  • @PokimBarran
    @PokimBarran 5 місяців тому

    Thanks

  • @devmaheswari4909
    @devmaheswari4909 5 місяців тому

    Hey thanks for the great video, while trying to implement the code receiving the error ""GetRemainingDistance" can only be called on an active agent that has been placed on a NavMesh." even though both NPC and ground have their following component NavMeshAgent and NavMeshSurface(surface is baked too). No idea how to solve this issue, it would be very helpful if you can help me out

  • @MuharremKose-xm2uu
    @MuharremKose-xm2uu 5 місяців тому

    Dude, you say add half of the character's height according to the pivot point of your character, I don't understand how difficult it is to specify where to add this

    • @oliverfekete4512
      @oliverfekete4512 2 місяці тому

      This is what the best thing I could have come up with: StartCoroutine(LerpVault(firstHit.point + (Vector3.up * playerHeight / 2f), 0.5f));

    • @oliverfekete4512
      @oliverfekete4512 2 місяці тому

      If you are slipping of the edge use this: StartCoroutine(LerpVault(firstHit.point + (Vector3.up * playerHeight / 2f) + (Vector3.forward * 0.3f), 1f));

  • @SleepDreamDev
    @SleepDreamDev 5 місяців тому

    BRO THANKS

  • @bvra155
    @bvra155 5 місяців тому

    I have been struggling myself on a specific issue. I have been trying to develop a multiplayer survival fps game and the thing is i am not too sure on how to animate the item holding animations, i want to make only one global animation from maybe the player model so that the item that will be instantiated in the hands will have the same positions on all clients. Or maybe should i make different animations on local and remote players. Any suggestions?

    • @BRIANROSER
      @BRIANROSER Місяць тому

      I would do completely seperate animations and models for the player vs opponents. Each client renders perfectly looking FPS rigs and animations that look right in FP. The opponents are then rendered with rigs and animations that look perfect in TP. Viola, no need to adjust anything to make it work in both views.

  • @ai-barq
    @ai-barq 5 місяців тому

    8:45 Caught Me Off Guard.

  • @misterioness4028
    @misterioness4028 5 місяців тому

    thanks it was quite a mystery on how we had hands visible

  • @WillowBruv3
    @WillowBruv3 5 місяців тому

    when i apply the script and then press play it doesn't start

  • @jondevtutorials4787
    @jondevtutorials4787 6 місяців тому

    For those asking about reload animations, if you want it to look professional you will most likely have to: 1) Create the animation in blender/unity (don't do it in unity), or just buy one / download one. 2) When its time to do the animation, disable the IK, then let the animation play 3) Re-enable it after the animation. Maybe you would want to use a game object to store where you animation starts so you can smoothly transition the gun position at the start. Personally I would just move the gun off screen or something because I hate working with animations.

    • @bigboy4432
      @bigboy4432 5 місяців тому

      i been thinking of importing the weapon and the arms separately and merge them both in the animations

  • @szotek-dg6il
    @szotek-dg6il 6 місяців тому

    but i want tutorial how to do it i dont want to copy and paste script

  • @Hyperforg
    @Hyperforg 6 місяців тому

    lol been trying to do this for ages with some goofy ass spaghetti code when I realised I can yoink the code. :p

  • @ricktherickrolled
    @ricktherickrolled 6 місяців тому

    oh my god it was THAT easy!!! Thank you so much!!

  • @vinnythehusky3481
    @vinnythehusky3481 7 місяців тому

    Question does anyone know how to make it work on VRCHAT?

  • @Vorkandor
    @Vorkandor 7 місяців тому

    For anyone else who has trouble with this: 1. Make sure to either name everything the same as Jon does or to rename them in the script file to what you've used. 2. By default the keys are 'E' to pick up/drop, hold 'R' and move mouse to rotate, and 'Left Click' to throw. This can be changed in the script. 3. Make sure the object you're picking up has a box collider and a rigidbody component. 4. Make sure on your camera (where you added the script) that 'Player' is set to the parent file of your camera movement. Hopefully, that helps some of you out. But if you're still stuck don't bother asking me for help. I just started learning Unity today, so idk lol.

    • @MASTERX-nw2gk
      @MASTERX-nw2gk 6 місяців тому

      You are amazing thank you !!!!.

    • @LucienLane
      @LucienLane 3 місяці тому

      i can get it a try