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.
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?
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.
@@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.
@@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.
@@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.
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
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; } } }
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 {
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;
@@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
Please watch the up to date version of this tutorial
ruclips.net/video/zgCV26yFAiU/видео.html
where your video update?
you made the video private
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!
can you send me the code i typed it but it did not work so i want to see if i did something wrong
Bro same
400th LIKE!!! This tutorial was exactly what I was looking for! TYSM
Yoooo underrated af! Definetely helped newbie me make some clean codes on unity! You deserve more recognition tho
Best tutorial in a while , good job and thanks :D
Thanks for tutorial after like 5 others yours is the only one that worked. Thanks again :D
My boy Vinnie with those throws!
Amazing tutorial man! Super easy to follow and he script works perfectly
Thank you so much !😃
Go, Vinny, Go! 🤣
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.
Amazing helped so much
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
super helpful thank you so so much
Hello! I dont know if you will see this, but how do i make it... Not jittery?
thank you, this is the only video works in RUclips
Thanks for this tutorial, but it's really jittery, do you think there is a way to fix that?
Great tutorial bro
thanks you are amazing teacher. Good luck
Thx for this tutorial its very good
Awesome!
Underrated
hey bro! what if i pickup a object and press r to delete it in my hand
How do i play an animation if i press Pickup and the Objekt is in range?
amazing
Why in my pickup layer doesn't show "pickup"
Poor Vinne Cant Breath 1:48
I bet you were laughing whenever you failed recording the intro about vinny
I would sure have if I were you
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?
the type Collider does not have the variable rotation. So do CurrentObjectCollider.transform.rotation
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!
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.
How fix jitter Bro?Please Help me!
great video!
One question though how can I make it so that it's smooth whenever I move my player Camera
For all the pickup objects in your game set their rigidbody interpolation mode to interpolate.
@@Rytech_Dev worked fine, still a bit jittery though
@@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.
@@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.
@@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.
the maaatrix
Could you make stealth game tutorial ?
That would be pretty fun. I will start working on it (:
thanks
0:49 since when was boxes sepheres ??????????????????
/:0
EDIT: really cool tho
Vinnie's boxes are odd...
Vinnie
Vinnie
Vinnie
Vinnie
Vinnie
Vinnie
This is not working for me whatsoever. I feel like I've set something up wrong...
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?
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
its jittery FIX PLZ
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;
}
}
}
}
}
Whats the error that you are getting
@@Rytech_Dev it just says complier errors
@@couthdragon does the name of your class match the .cs file?
@@Rytech_Dev yeah
@@couthdragon If it just says "compiler errors" and doesn't give you any further information, just start a fresh new project.
can u send me the full script plz?
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;
}
}
}
@@hareyold3460 thank you.
do you remember? Next is choping trees😺😁
yep
TSYM!!!
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
Bro the boxes are named sphere 🤣🤣🤣🤣🤣🤣
Shhhhhhh
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;
}
}
Gog
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;
}
}
}
What error are you getting?
@@Rytech_Dev Nope
@@madhatter2497 I wouldn't worry too much because I am going to make a redo of this tutorial.
@@Rytech_Dev Nice
@@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