FULL PICK UP & DROP SYSTEM for WEAPONS or ITEMS || Unity3d Tutorial

preview_player
Показать описание
FULL PICK UP & DROP SYSTEM || Unity3d Tutorial:
Since I just started my series on how to shoot with projectiles in Unity, I thought it would be cool to share how to make a full pick up and drop system :D

Don't forget to subscribe if you enjoyed the video, and if you have any questions just write a comment, I'll answer as many as I can! :D

Links:

If you want here's the series about the GUN SYSTEM USED in the video:

🏹 Get Access to my RANGED COMBAT LAB! 🏹

➡️ Get Access to my full MOVEMENT LAB! ➡️

Other interesting videos :D

Support me on Patreon:

Music used:

#UnityTutorial #PickUpWeapon #Unity3d
Рекомендации по теме
Комментарии
Автор

If you need help with any of the code shown, just visit the "coding-help" channel on my discord server :D
Also you can find many more tutorials on my channel in the "Tutorials!" playlist - I really hope they help you on your further GameDev journey!

And in case you're interested in getting access to my full RANGED COMBAT LAB, with which you can create pretty much any ranged ability/weapon you can think of, check out the trailer:

Thanks so much for watching, hope this tutorial has helped you!

davegamedevelopment
Автор

I almost cried as it worked, i spent over 10h on it

creapermann
Автор

This guy is such a good youtuber. He creates full, easy to understand tutorials and responds to almost every comments even if it's off topic. 100% liked and subbed :)

taylormarinescu
Автор

Here's the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PickupGun : MonoBehaviour
{
public Gun gunScript;
public Rigidbody rb;
public BoxCollider coll;
public Transform player, gunContainer, fpsCam;

public float pickUpRange;
public float dropForwardForce, dropUpwardForce;

public bool equipped;
public static bool slotFull;

private void Start()
{
if (!equipped)
{
gunScript.enabled = false;
rb.isKinematic = false;
coll.isTrigger = false;
}
if (equipped)
{
gunScript.enabled = true;
rb.isKinematic = true;
coll.isTrigger = true;
slotFull = true;
}
}
private void Update()
{
Vector3 distaceToPlayer = player.position - transform.position;
if (!equipped && distaceToPlayer.magnitude <= pickUpRange && Input.GetKeyDown(KeyCode.E) && !slotFull) PickUp();

if (equipped && Input.GetKeyDown(KeyCode.Q)) Drop();
}

private void PickUp()
{
equipped = true;
slotFull = true;


transform.localPosition = Vector3.zero;
transform.localRotation =
transform.localScale = Vector3.one;

rb.isKinematic = true;
coll.isTrigger = true;

gunScript.enabled = true;
}

private void Drop()
{
equipped = false;
slotFull = false;

transform.SetParent(null);

rb.isKinematic = false;
coll.isTrigger = false;

rb.velocity =

rb.AddForce(fpsCam.forward * dropForwardForce, ForceMode.Impulse);
rb.AddForce(fpsCam.up * dropUpwardForce, ForceMode.Impulse);

float random = Random.Range(-1f, 1f);
rb.AddTorque(new Vector3(random, random, random) * 10);

gunScript.enabled = false;
}
}

disgraceme
Автор

This man deserves more support his tutorials are amazing! I’m writing this comment to show all the support I can!

crazykidplayz
Автор

This Guy Is A Such A Good Person, He Gives The Codes And Understands We Easily

itztecherz
Автор

my game just became 1 step closer 2 done. Thank you so much for this tutorial!

Broskibrow
Автор

Coming back to these tutorials after learning c# and they are so much easier to understand!

decidev
Автор

Hi I've been working on top down 2d game and cant really find a good tutorial for pickup and drop weapons so I have no choice but to use this tutorial and after editing the whole script to work with 2d I've manage to make it work so awesome thanks for this tutorial helpful enough!

Justeeee
Автор

Set Interpolate to :None
if your object is not moving as your view camera.

ilypavan
Автор

Thanks, i tried the last month to do a good pick up and drop script cause there is no one on youtube. You just got one new active member :) TY

creapermann
Автор

top 10% of Unity tutorials right here, and I've sure as hell watched pretty much all of them

tabithagiblet
Автор

im so glad i can find a tutorial youtuber like you bc most of the other youtubers are just like do this do that then you will have this. but u explain what everything means wich is very helpful for beginners like me.

Iam_tails
Автор

To everyone who has the problem with this line:" public ProjectileGun gunScript;" u have to use instead of ProjectileGun the name of the gun script u have to shoot and stuff. So Get the name from the gun script and put it instead of "ProjectielGun". for example it should look like this :public Gun gunScript;

Kosten
Автор

Thank you, I hope you helped many people, for some reason, this broke my entire game having to completely restart. Nothing against you, probably something i did wrong, but i hope you can help other people

skyblade_studios
Автор

You my good sir is a legend among this community, insane tutorial💪🏻

theokruger
Автор

this guy is as good as Brackeys (R.I.P Brackeys YT Channel)

keilithdevine
Автор

Absolutely amazing, thank you so much, my player can now pick up a flashlight in my horror game! 😁

lucasburford
Автор

Thankyou so much Dave, works very well making my game so much better!

cybertechlite
Автор

Very nice
Used it in my.personal project.
Working well
Enjoying playing with the script.

BadBanana
join shbcf.ru