How to Make a Pick up System in UNITY With Rigidbodies [C#] [Unity3D]

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ม.ค. 2025

ความคิดเห็น • 94

  • @Rytech_Dev
    @Rytech_Dev  3 ปีที่แล้ว +7

    Please watch the up to date version of this tutorial
    th-cam.com/video/zgCV26yFAiU/w-d-xo.html

    • @fakruladly1118
      @fakruladly1118 11 หลายเดือนก่อน

      where your video update?

    • @Horrorbutterz
      @Horrorbutterz 9 หลายเดือนก่อน

      you made the video private

  • @Paragorax
    @Paragorax 3 ปีที่แล้ว +7

    I have to say, well done, ive been through at least 3 other tutorials, all of which failed. but with yours i was finally able to do it! thank you!

    • @couthdragon
      @couthdragon 3 ปีที่แล้ว

      can you send me the code i typed it but it did not work so i want to see if i did something wrong

    • @Neepo1220
      @Neepo1220 2 ปีที่แล้ว

      Bro same

  • @TheDuccyGaming
    @TheDuccyGaming ปีที่แล้ว

    400th LIKE!!! This tutorial was exactly what I was looking for! TYSM

  • @TheDaltonsUk
    @TheDaltonsUk 3 ปีที่แล้ว +1

    Best tutorial in a while , good job and thanks :D

  • @Neepo1220
    @Neepo1220 2 ปีที่แล้ว

    Thanks for tutorial after like 5 others yours is the only one that worked. Thanks again :D

  • @ivansnav
    @ivansnav 3 ปีที่แล้ว

    Yoooo underrated af! Definetely helped newbie me make some clean codes on unity! You deserve more recognition tho

  • @More_NickMaster
    @More_NickMaster 3 ปีที่แล้ว +1

    My boy Vinnie with those throws!

  • @barrelbrothers6896
    @barrelbrothers6896 2 ปีที่แล้ว +1

    Amazing tutorial man! Super easy to follow and he script works perfectly

  • @audiofrank6747
    @audiofrank6747 2 ปีที่แล้ว

    Thank you so much !😃

  • @fernandodasilva-producoesa1023
    @fernandodasilva-producoesa1023 9 หลายเดือนก่อน

    Thank you very much, very simple to implement. I now only need to clean my code and see if i can implement this into an interface or a different function.

  • @fagnersales532
    @fagnersales532 2 ปีที่แล้ว

    Awesome!

  • @benymona-moke9419
    @benymona-moke9419 2 ปีที่แล้ว

    Amazing helped so much

  • @1ks_SPOT
    @1ks_SPOT 2 ปีที่แล้ว

    thanks you are amazing teacher. Good luck

  • @PhoneUser89
    @PhoneUser89 ปีที่แล้ว

    Underrated

  • @PP-qw3yr
    @PP-qw3yr 3 ปีที่แล้ว

    thank you, this is the only video works in TH-cam

  • @aquafina2on217
    @aquafina2on217 3 ปีที่แล้ว

    super helpful thank you so so much

  • @onlyrxtro7059
    @onlyrxtro7059 7 หลายเดือนก่อน +1

    Is it a way to make it to where only I can pick it up and nobody else able to touch it even when I drop it

  • @brylinx1451
    @brylinx1451 3 ปีที่แล้ว

    Great tutorial bro

  • @duyphatnguyenmai9853
    @duyphatnguyenmai9853 2 ปีที่แล้ว

    amazing

  • @mate20xg
    @mate20xg 3 ปีที่แล้ว

    Thx for this tutorial its very good

  • @petarashmalaj
    @petarashmalaj ปีที่แล้ว

    Go, Vinny, Go! 🤣

  • @edij100
    @edij100 7 หลายเดือนก่อน +1

    Hello! I dont know if you will see this, but how do i make it... Not jittery?

  • @nodis-l9l
    @nodis-l9l หลายเดือนก่อน

    Thanks for this tutorial, but it's really jittery, do you think there is a way to fix that?

  • @nayefmsh8274
    @nayefmsh8274 2 ปีที่แล้ว

    I bet you were laughing whenever you failed recording the intro about vinny
    I would sure have if I were you

  • @ShadowForgeBG
    @ShadowForgeBG 2 ปีที่แล้ว

    Why in my pickup layer doesn't show "pickup"

  • @big03145
    @big03145 2 ปีที่แล้ว

    hey bro! what if i pickup a object and press r to delete it in my hand

  • @schnippeldifit7805
    @schnippeldifit7805 2 ปีที่แล้ว

    the maaatrix

  • @thefirstblank607
    @thefirstblank607 2 ปีที่แล้ว

    How do i play an animation if i press Pickup and the Objekt is in range?

  • @ehansytaxian
    @ehansytaxian 2 ปีที่แล้ว

    Poor Vinne Cant Breath 1:48

  • @hyperadoi
    @hyperadoi 3 ปีที่แล้ว

    bro where i writed CurrentObjectCollider.rotation = Hand.rotation; they showed me an error where they say "Assets\Pickup.cs(43,36): error CS1061: 'Collider' does not contain a definition for 'rotation' and no accessible extension method 'rotation' accepting a first argument of type 'Collider' could be found (are you missing a using directive or an assembly reference?)" what is the problem?

    • @Rytech_Dev
      @Rytech_Dev  3 ปีที่แล้ว

      the type Collider does not have the variable rotation. So do CurrentObjectCollider.transform.rotation

  • @legend3305
    @legend3305 3 ปีที่แล้ว +1

    0:49 since when was boxes sepheres ??????????????????
    /:0
    EDIT: really cool tho

    • @Rytech_Dev
      @Rytech_Dev  3 ปีที่แล้ว

      Vinnie's boxes are odd...

  • @zombboi
    @zombboi 3 ปีที่แล้ว

    Is there a way to do it with Tags? All of my objects need to be on the Ground layer to work properly. Thanks in advance!

    • @Rytech_Dev
      @Rytech_Dev  3 ปีที่แล้ว

      You can use GameObject.CompareTag(); function. Get rid of the extra layermask parameter on the raycast and in the if statement for the raycast use the comparetag function.

  • @ryvenenennnn
    @ryvenenennnn 2 ปีที่แล้ว

    thanks

  • @recon4697
    @recon4697 3 ปีที่แล้ว

    great video!
    One question though how can I make it so that it's smooth whenever I move my player Camera

    • @Rytech_Dev
      @Rytech_Dev  3 ปีที่แล้ว

      For all the pickup objects in your game set their rigidbody interpolation mode to interpolate.

    • @recon4697
      @recon4697 3 ปีที่แล้ว

      @@Rytech_Dev worked fine, still a bit jittery though

    • @Rytech_Dev
      @Rytech_Dev  3 ปีที่แล้ว

      @@recon4697 I guess another thing you could try is putting your movement code in LateUpdate or fixedupdate functions alongside with the interpolation on the rigidbody.

    • @recon4697
      @recon4697 3 ปีที่แล้ว

      @@Rytech_Dev didn't work, it only made my movement delayed. Thanks for the help though and keep up the great work!
      although if you could think of anything else I'd appreciate it.

    • @recon4697
      @recon4697 3 ปีที่แล้ว

      @@Rytech_Dev Also I tried multiplying Time.deltaTime by hand.position just to see what would happen, and the jittery part was fixed but the position was set to the cameras position.

  • @fakruladly1118
    @fakruladly1118 11 หลายเดือนก่อน

    How fix jitter Bro?Please Help me!

  • @smileplz3345
    @smileplz3345 2 หลายเดือนก่อน

    its jittery FIX PLZ

  • @joeyestrada9071
    @joeyestrada9071 ปีที่แล้ว

    This is not working for me whatsoever. I feel like I've set something up wrong...

  • @troisot1107
    @troisot1107 3 ปีที่แล้ว

    Could you make stealth game tutorial ?

    • @Rytech_Dev
      @Rytech_Dev  3 ปีที่แล้ว

      That would be pretty fun. I will start working on it (:

  • @calisthenicswithandrew7183
    @calisthenicswithandrew7183 2 ปีที่แล้ว

    It's a perfect tutorial, but can you please make a tutorial on how to resolve the glitchy thing at the object when we move?

    • @calisthenicswithandrew7183
      @calisthenicswithandrew7183 2 ปีที่แล้ว

      And yea, I know you made a updated tutorial but I want the character to hold the objects in his hand, not to move objects in the air, thank you!
      Also, I like your content

  • @Rytech_Dev
    @Rytech_Dev  3 ปีที่แล้ว +3

    Vinnie

  • @DeletedAccount385
    @DeletedAccount385 3 ปีที่แล้ว

    do you remember? Next is choping trees😺😁

  • @Gowy_YT
    @Gowy_YT 2 ปีที่แล้ว

    TSYM!!!

  • @couthdragon
    @couthdragon 3 ปีที่แล้ว

    ok i think i did something wrong or this just does not work in 2020.3 it says there are complier errors here is the code i use what did i do wrong i know that this is not the finished code it is from when he first when back to the game
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class pickupclass : MonoBehaviour
    {
    [SerializeField] private LayerMask PickupLayer;
    [SerializeField] private Camera PlayerCamera;
    [SerializeField] private float PickupRange;
    private Rigidbody CurrentObjectRigidbody;
    private Collider CurrentObjectCollider;
    // Update is called once per frame
    void Update()
    {
    if (Input.GetKeyDown(KeyCode.E))
    {
    Ray Pickupray = new Ray(PlayerCamera.tranform.postion, PlayerCamera.transfom.forward);
    if (Physics.Raycast(Pickupray, out RaycastHit hitInfo, PickupRange, PickupLayer))
    {
    if (CurrentObjectRigidbody)
    {
    }
    else
    {
    CurrentObjectRigidbody = hitInfo.rigidBody;
    CurrentObjectCollider = hitInfo.collider;
    CurrentObjectRigidbody.isKinematic = true;
    CurrentObjectCollider.enabled = false;
    }
    }
    }

    }
    }

    • @Rytech_Dev
      @Rytech_Dev  3 ปีที่แล้ว

      Whats the error that you are getting

    • @couthdragon
      @couthdragon 3 ปีที่แล้ว

      @@Rytech_Dev it just says complier errors

    • @Rytech_Dev
      @Rytech_Dev  3 ปีที่แล้ว

      @@couthdragon does the name of your class match the .cs file?

    • @couthdragon
      @couthdragon 3 ปีที่แล้ว

      @@Rytech_Dev yeah

    • @Rytech_Dev
      @Rytech_Dev  3 ปีที่แล้ว

      @@couthdragon If it just says "compiler errors" and doesn't give you any further information, just start a fresh new project.

  • @zilvanilab7219
    @zilvanilab7219 3 ปีที่แล้ว

    can u send me the full script plz?

    • @hareyold3460
      @hareyold3460 3 ปีที่แล้ว +5

      i know this is really late and youve probably moved on but here:
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      public class PickupClass : MonoBehaviour
      {
      [SerializeField] private LayerMask PickupLayer;
      [SerializeField] private Camera PlayerCamera;
      [SerializeField] private float ThrowingForce;
      [SerializeField] private float PickupRange;
      [SerializeField] private Transform Hand;
      private Rigidbody CurrentObjectRigidbody;
      private Collider CurrentObjectCollider;
      void Update()
      {
      if (Input.GetKeyDown(KeyCode.E))
      {
      Ray Pickupray = new Ray(PlayerCamera.transform.position, PlayerCamera.transform.forward);
      if (Physics.Raycast(Pickupray, out RaycastHit hitInfo, PickupRange, PickupLayer))
      {
      if (CurrentObjectRigidbody)
      {
      CurrentObjectRigidbody.isKinematic = false;
      CurrentObjectCollider.enabled = true;
      CurrentObjectRigidbody = hitInfo.rigidbody;
      CurrentObjectCollider = hitInfo.collider;
      CurrentObjectRigidbody.isKinematic = true;
      CurrentObjectCollider.enabled = false;
      }
      else
      {
      CurrentObjectRigidbody = hitInfo.rigidbody;
      CurrentObjectCollider = hitInfo.collider;
      CurrentObjectRigidbody.isKinematic = true;
      CurrentObjectCollider.enabled = false;
      }
      return;
      }
      if (CurrentObjectRigidbody)
      {
      CurrentObjectRigidbody.isKinematic = false;
      CurrentObjectCollider.enabled = true;
      CurrentObjectRigidbody = null;
      CurrentObjectCollider = null;
      }
      }
      if (Input.GetKeyDown(KeyCode.Q))
      {
      if (CurrentObjectRigidbody)
      {
      CurrentObjectRigidbody.isKinematic = false;
      CurrentObjectCollider.enabled = true;
      CurrentObjectRigidbody.AddForce(PlayerCamera.transform.forward * ThrowingForce, ForceMode.Impulse);
      CurrentObjectRigidbody = null;
      CurrentObjectCollider = null;
      }
      }
      if (CurrentObjectRigidbody)
      {
      CurrentObjectRigidbody.position = Hand.position;
      CurrentObjectRigidbody.rotation = Hand.rotation;
      }
      }
      }

    • @zilvanilab7219
      @zilvanilab7219 2 ปีที่แล้ว

      @@hareyold3460 thank you.

  • @DanRobart
    @DanRobart ปีที่แล้ว

    Bro the boxes are named sphere 🤣🤣🤣🤣🤣🤣

  • @dr.albitros4242
    @dr.albitros4242 2 ปีที่แล้ว

    I personaly use my own metod. It's kinda different than your's, but i think it's cool. But still, this tut is cool

  • @mangomctango1802
    @mangomctango1802 3 ปีที่แล้ว +1

    it says some where in my code there is a misplaced ";" but i can't find it.
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class pickup : MonoBehaviour
    {

    [SerializeField] private LayerMask PickupLayer;
    [SerializeField] private Camera PlayerCamera;
    [SerializeField] private ThrowingForce;
    [SerializeField] private float PickupRange;
    [SerializeField] private Transform Hand;
    private Rigidbody CurrentObjectRigidbody;
    private Collider CurrentObjectCollider;
    void Update()
    {
    if(Input.GetKeyDown(KeyCode.E))
    {
    Ray Pickupray = new Ray(PlayerCamera.transform.position, PlayerCamera.transform.forward);
    if(Physics.Raycast(Pickupray, out RaycastHit hitInfo, PickupRange, PickupLayer))
    {
    if(CurrentObjectRigidbody)
    {
    CurrentObjectRigidbody.isKinematic = false;
    CurrentObjectCollider.enabled = true;
    CurrentObjectRigidbody = hitInfo.rigidbody;
    CurrentObjectCollider = hitInfo.collider;
    CurrentObjectRigidbody.isKinematic = true;
    CurrentObjectCollider.enabled = false;
    }
    else
    {
    CurrentObjectRigidbody = hitInfo.rigidbody;
    CurrentObjectCollider = hitInfo.collider;
    CurrentObjectRigidbody.isKinematic = true;
    CurrentObjectCollider.enabled = false;
    }
    return;
    }

    if(CurrentObjectRigidbody)
    {
    CurrentObjectRigidbody.isKinematic = false;
    CurrentObjectCollider.enabled = true;
    CurrentObjectRigidbody = null;
    CurrentObjectCollider = null;
    }
    }

    if(Input.GetKeyDown(KeyCode.Q))
    {
    if(CurrentObjectRigidbody)
    {
    CurrentObjectRigidbody.isKinematic = false;
    CurrentObjectCollider.enabled = true;
    CurrentObjectRigidbody.AddForce(PlayerCamera.transform.forward * ThrowingForce, ForceMode.Impulse);
    CurrentObjectRigidbody = null;
    CurrentObjectCollider = null;
    }
    }

  • @madhatter2497
    @madhatter2497 3 ปีที่แล้ว +1

    I finished the whole thing but at the end the script didn't work and I barley understand why it is happening here is the code
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class PickUp : MonoBehaviour
    {
    [SerializeField] private LayerMask PickupLayer;
    [SerializeField] private Camera PlayerCamera;
    [SerializeField] private float PickupRange;
    [SerializeField] private Transform Hand;
    [SerializeField] private float force;
    private Rigidbody rb;
    private Collider Collider;

    // Update is called once per frame
    void Update()
    {
    if (Input.GetKeyDown(KeyCode.E))
    {
    Ray Pickupray = new Ray(PlayerCamera.transform.position, PlayerCamera.transform.forward);
    if (Physics.Raycast(Pickupray, out RaycastHit hitinfo, PickupRange, PickupLayer))
    {
    if (rb)
    {
    rb.isKinematic = false;
    Collider.enabled = true;
    rb = hitinfo.rigidbody;
    Collider = hitinfo.collider;
    rb.isKinematic = true;
    Collider.enabled = false;
    }
    else
    {
    rb = hitinfo.rigidbody;
    Collider = hitinfo.collider;
    rb.isKinematic = true;
    Collider.enabled = false;
    }
    return;
    }
    }
    if (rb)
    {
    rb.isKinematic = false;
    Collider.enabled = true;
    rb = null;
    Collider = null;

    }
    if (Input.GetKeyDown(KeyCode.Q))
    {
    if (rb)
    {
    rb.isKinematic = false;
    Collider.enabled = true;
    rb = null;
    Collider = null;
    rb.AddForce(PlayerCamera.transform.forward * force, ForceMode.Impulse);
    }
    }
    if (rb)
    {
    rb.position = Hand.position;
    rb.rotation = Hand.rotation;
    }

    }
    }

    • @Rytech_Dev
      @Rytech_Dev  3 ปีที่แล้ว

      What error are you getting?

    • @madhatter2497
      @madhatter2497 3 ปีที่แล้ว

      @@Rytech_Dev Nope

    • @Rytech_Dev
      @Rytech_Dev  3 ปีที่แล้ว

      @@madhatter2497 I wouldn't worry too much because I am going to make a redo of this tutorial.

    • @madhatter2497
      @madhatter2497 3 ปีที่แล้ว

      @@Rytech_Dev Nice

    • @madhatter2497
      @madhatter2497 3 ปีที่แล้ว

      @@Rytech_Dev I just found a error in it UnassignedReferenceException: The variable PlayerCamera of PickUp has not been assigned.
      You probably need to assign the PlayerCamera variable of the PickUp script in the inspector.
      PickUp.Update () (at Assets/Scripts/PickUp/PickUp.cs:24)
      idk what this even means and I have gone though the script