I'm having problems with the last part in which we should see the number of items collected. It doesn't change. In addition, inside Inspector -> yer Inventory (Script) -> InventoryUI, UpdateDiamondText doesn't appear, why? (I followed all the steps and copied the codes)
I'm also getting that bug where the Unity event is not showing the Update player inventory thing. it was working fine on 2020.3 , but on my new project in 2021.3 it isn't working
Hi, that's strange. I've upgraded the project to 2021.3 and it seems to work fine. As an alternative, you can make the event a plain event e.g. public UnityEvent OnDiamondCollected; Then you can select the PlayerInventory in the Inspector when wiring up the event. Hope that helps 😊
I figured it out the text issue but I have another issue. The updated playerinventory script works fine but the subscriber list doesn't appear or show up. Please help! ASAP!
Hi, I think this will be a limitation with the version of Unity you're using not supporting generic events. As an alternative you can make the event a plain event e.g. public UnityEvent OnDiamondCollected; Then you can select the PlayerInventory in the Inspector when wiring up the event. Hope that helps 😊
Hi, you could store a reference to the diamond in the OnTriggerEnter method. Then you could remove the reference in the OnTriggerExit method. Then in Update you could check for the button press and pick up the diamond if the reference is not null. Hope that helps 😊
Hi, thanks. You could add another script that contains a method that checks the number of items collected and then executes your desired action. Then you could wire up the collected event to this new method. Hope that helps 😊
@@KetraGames Is there any chance we could get some code written out for this method to check the number of items? I'm trying to do something similar but I keep getting an error saying that the playerInventory is non-invocable. Here's the code I've written below: public class PhotoAppear : MonoBehaviour { PlayerInventory playerInventory = GetComponent(); void Start() { gameObject.SetActive(false); } // Update is called once per frame public void Update() { if (playerInventory.NumberOfPhotos() == 5) { gameObject.SetActive(true); } return; } } As well, thank you for this tutorial, what it covered was very easy to follow and understand.
Hi, good question. There are a few ways you can pass data between scenes 1. You can use PlayerPrefs to save and load data between scenes - docs.unity3d.com/ScriptReference/PlayerPrefs.SetInt.html 2. Game Objects can survive between scenes if you set DontDestroyOnLoad so this may be a possibility - docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html 3. Another option is to store the data in a ScriptableObject which will then persist across scenes - docs.unity3d.com/Manual/class-ScriptableObject.html Hope that helps 😊
Hi, to play a sound you need to have an audio source. Because the diamond is disabled when it's collected, it won't be able to play the sound itself. Therefore, you will need to add an audio source to the Player object. You can then play as sound using AudioSource.PlayOneShot - docs.unity3d.com/ScriptReference/AudioSource.PlayOneShot.html Hope that helps 😊
@@alejandraalcocer9857 @KetraGames and anyone else looking to add sound to these collectibles...I found a solution :) I made a tutorial here: ruclips.net/video/mA9UQwjykpk/видео.html ...basically just add a parent to your diamond and give that its own bigger collider, audio source, and the "Play Sound on Enter" script in the tutorial :)
Thanks 😊 If you wanted the diamond to increase the count by more than 1 you could change the line in the PlayerInventory. So rather than NumberOfDiamonds++; you could do NumberOfDiamonds+= 10; Hope that helps 😊
Hello, I have everything setup like in the video but when my character walks into the diamonds it does not collect them but they are solid instead and it just collides. It seems like a problem in my diamond script detecting player collision but everything is setup as in the video so I'm not sure what the issue is?
@vmbrine You said it does send you an error? Could you send the details of the error if there is one. Otherwise, it's a matter of debugging to see where the issue is. You can either put breakpoints in the code and step through if you know how to do that. Or you can add Debug.Log lines in to see where it gets to before it fails.
Great tutorial. I have encountered an issue however with the last step ... public UnityEvent OnPickUpCollected; is not exposed in the inspector even with adding [SerializeField]. From what I gather this is a unity bug, any thoughts on a work around?
Hi, I can't think of why it wouldn't be visible. Are you seeing any errors in the Console window? If you still can't get it to work, try copying the script form here - dotnetfiddle.net/Rzs92c Hope that helps 😊
@@KetraGames Thank you for the quick response! No errors in console. When researching this issue I found lots of posts claiming this was a unity bug issue with exposing unity events in the inspector. Some suggested you could get around this issue using [System.Serializable]. The example is: "I have found the way. first you have to define your own event type (which is just a basic public class). however the custom event type must inherit from UnityEvent, like so." [System.Serializable] public class myFloatEvent : UnityEvent{} "then you can make variables from it, like so." [SerializeField] public myFloatEvent onChangeEvent; I'm just not sure how to refactor this to work with your example.
Hi thanks for the great tutorials. I'm getting the same error at this point also, i have the latest versions of unity and visual studio my character has [SerializedField] On a third person shooter controller. Not sure if this would have any effect?!🤷♂️
Hello , i have 3 object to collect and what should i do to collect it in order if 1 is not collected 2 is collected,then of 1 is collected and 2 collected?
Another perfect tutorial by Ketra Games :) Thank you very much. May I ask a question: I've got two characters in the game but player can use both of them by swaping. I assigned the PlayerInventory script both of them and it works, BUT once the character#1 collects some diamonds and if I swap to the character#2 and collect any diamond then die diamond collection amount RESETS to 1. It seems Unity or the script keeps the amount for each character seperately, which is fine btw, but 1st Question= how can I show the amount of diamond collection amount of each character on canvas seperately? 2nd Question = how can I show the total diamond collection amount (without resetting) on the same canvas / text area? Many Thanks !
Hey, first of all i love your tutorials on unity, but i've been watching countless tutorials, blog posts and The unity guide and can't find anything about persistent collectable couter, how can i make it that when i collect 7 collectables in one level that i start the next one with 7?
Hi, you would need to persist this between scenes. There are several options to do this. You can use a static variable, Unity's Player Prefs, or you can serialise to disk and load it back in again. Hope that helps 😊
Hi, you would need to keep track of how many diamonds are left in the scene. You could write a script that gets the count of diamonds in the scene in the Awake method. Then subscribe to the diamond collected event and decrease this count each time. Once you reach zero you can initialise the object you want. Hope that helps 😊
@@KetraGames it's like i want an item to spawn at a certain location after a player collects 7 diamonds i made a parkour game that you can only win by collecting a special item but i want that item to only spawn when you collect a specific amount of gems . I'm a beginner with no knowledge of coding but I'm halfway done with my game I'm making with just tutorial
@@shang_psycho7414 Hi, you would need to keep track of how many collectables are still active in the scene. Once you reach zero then you can trigger the scene change.
At the very beginning: big hugs to you💚! You do wonderful tutorials for beginners, I learn a lot from your videos. Thank you! I used this video to add scripts to an existing project that I have been working on for a while. I already have a canvas for Game Over. I did what you did in this video, no bugs, player can collect diamonds but unfortunately nothing is charged on the canvas. I watched the tutorial again and I don't know where the error may be. I know it's hard to answer something "out of the head", but maybe someone has an idea?🙄
Hi, glad you're finding the videos useful. Have you set up the event handler in the Inspector to update the canvas when a diamond is collected? If so, it might be worth adding a Debug.Log line in the method you're calling from the event handler, to make sure it is getting called. Hope that helps 😊
Great tutorials. However im runing into an error with this one, even if i copy your code from the fiddle link. ArgumentException: Object of type 'UnityEngine.Object' cannot be converted to type 'PlayerInventory'. I get this error when i implement the last steps. Everything works fine up till then. The gems gets picked up and removed but at soon as i want to send the number of gems to the UI i get the error. And only when i attempt to pick up the gems.
Hi, can you check that when you trigger the event in the PlayerInventory script, that you're passing through 'this' OnDiamondCollected.Invoke(this); That should pass the PlayerInventory through to the UI script. If that doesn't work you could try changing the event to just be a general event public UnityEvent OnDiamondCollected; Then when you wire up the event in the Inspector, there should be an extra slot for the PlayerInventory that you can drag the Player object into. Hope that helps 😊
Hi, you would need to create another script to do this. You could still hook up the diamond collected event to this new script but check if the total has reached 20 before making the text visible. Hope that helps 😊
Hiya, Thanks for the nice video, was easy to follow. Bit of a plot twist for me though - I'm using 2D so maybe that's the problem. Basically I have a fireball that comes down and I want my character to collect it. The fireball has a rigidbody, circular collider and bouncy physics. When it hits my dragon it doesn't get collected - any ideas?
HIIII! Amazing tutorial! Do you think this is doable on an AR game? I'm trying to figure out if there's any possibility to collect an AR element and put it into an inventory (ideally on click as it is an android app) yet I didn't manage to find any tutorial on this topic :( Any advice? Thanks!
Hi, the box collider position is linked to the transform of the object it is attached. You can change the center position to offset it however you want. Hope that helps 😊
Hi, I have a problem. I have all the scripts copied and put into the correct objects but there's something wrong. When I go to my character the Player Inventory script doesn't show the thing where I can select the function of OnDiamondCollected. Plus, when I try to test the game and grab the collectables it just throws me this error: "NullReferenceException: Object reference not set to an instance of an object PlayerInventory.DiamondCollected () (at Assets/PlayerInventory.cs:13) Diamond.OnTriggerEnter (UnityEngine.Collider other) (at Assets/Diamond.cs:13)" By the way, I'm using Unity 2019.4.40f1 Personal. Maybe that has something to do? If you can help I'd thank you a lot.
how to collect the diamond in order like in diamond1 diamond 2 diamond 3 , if diamond 1 one is collected you cannot collect the diamond 2 and diamond 3.
Please help! This was an awesome tutorial, but I can't find 1 thing on the internet that explains how to load next scene if all objects are collected!!!
A beginner question, in the "InventoryUI" script, why did you put argument for the "UpdateDiamondText" method? What was the source of that argument to make the method work? Thank you,
Hi, the UpdateDiamondText uses the PlayerInventory parameter to get the number of diamonds that have been collected. playerInventory.NumberOfDiamonds.ToString(); This is passed through when the event is invoked from the PlayerInventory. OnDiamondCollected.Invoke(this); In this case 'this' refers to the PlayerInventory invoking the event. Hope that makes sense 😊
If you are looking to add sound to these collectibles where it plays once...I found a solution :) I made a tutorial here: ruclips.net/video/uazpON_0JdA/видео.html (Edited because the parent object sound didn't always work, and you couldn't keep it from playing anytime you entered the area even if collectable was gone). ...basically just add a sound object on top of the collectable... and give that its own collider, audio source, and the "Play Sound on Enter" script in the tutorial :) I got the sound script from @ChrisTutorialsYT ruclips.net/video/E7-HAJ4Db64/видео.html, then I added a bool for "if already played".
QUESTION: Are the public class names just the name of the C# script. For example, public class PlayerInventory : Monobehaviour; because the filename is called PlayerInventory.
Hi, you could generate a navmesh for the walkable area of your terrain. Then you could find random points on the navmesh to place diamonds. This link may help answers.unity.com/questions/475066/how-to-get-a-random-point-on-navmesh.html
@@KetraGames Thank you for replying so quickly. Actually you know what, i am a total beginner and i have to submit my project after 2 days. So can you please make a quick video on this topic i am sure many us want a video on topic. Please
For anyone having trouble selecting InventoryUI in the last step, make sure you attached it to the text!!! Thank you, this tutorial was very helpful!
Man that was delightful. After all those rushy tutorials this series is a breath of fresh air. Thank you!
Thanks very much for this 😊
This series is clear, simple concept, well planned and fun to follow. Thank you! I'm really looking forward on seeing more of these videos!
Thanks for this great comment 😊
Thank you for this beginner friendly tutorial. I'm waiting for your next tutorial.
Great to hear, thank you 😊
I'm having problems with the last part in which we should see the number of items collected. It doesn't change. In addition, inside Inspector -> yer Inventory (Script) -> InventoryUI, UpdateDiamondText doesn't appear, why? (I followed all the steps and copied the codes)
This was super helpful. Didn't know about the events system!
Glad it was useful 😊
I'm also getting that bug where the Unity event is not showing the Update player inventory thing. it was working fine on 2020.3 , but on my new project in 2021.3 it isn't working
Hi, that's strange. I've upgraded the project to 2021.3 and it seems to work fine. As an alternative, you can make the event a plain event e.g. public UnityEvent OnDiamondCollected; Then you can select the PlayerInventory in the Inspector when wiring up the event. Hope that helps 😊
Hi I cant seem to find the update diamond text method, can you help me?
Hi, the full script can be found here - dotnetfiddle.net/Rzs92c
Hope that helps 😊
I figured it out the text issue but I have another issue. The updated playerinventory script works fine but the subscriber list doesn't appear or show up. Please help! ASAP!
Hi, I think this will be a limitation with the version of Unity you're using not supporting generic events. As an alternative you can make the event a plain event e.g. public UnityEvent OnDiamondCollected; Then you can select the PlayerInventory in the Inspector when wiring up the event. Hope that helps 😊
How would you reference the number of collected items in another script? Im trying to make it so that once i pickup 10 an achievement pops
finally someone who didn't use destroy function on collectable.
Thank you, please more tutorials 😊 ,very good tutorials!
Glad you're finding them useful 😊
Most clear video to understand;
Great to hear this, thanks 😊
does anyone know how to get a "you win" page when the player have collected 10 items?
If you figure it out let me know I'm looking for the same question
thank you this was a big help in my game!!
Great to hear this 😊
Thanks!
it worked for my mobile game!
How can I make the item only be pickd up whn a player is holding a certain key?
Hi, you could store a reference to the diamond in the OnTriggerEnter method. Then you could remove the reference in the OnTriggerExit method. Then in Update you could check for the button press and pick up the diamond if the reference is not null. Hope that helps 😊
@@KetraGames hi, i would love to do this for my game, but it doesn't make sense to me, could you explain it in more detail, im a beginner
TYSM IT HELPED MY GAME SOO MUCH
Great to hear, thanks 😊
I love u so much thank you for helping this helped for my project
Great to hear, thank you 😊
I can't use TMPro in my unity project because I'm using unity 5.6.7f1 and textmeshpro isn't available. Please help
Cancel that comment
Well made tutorial, easy to follow. What if you wanted to play a sound whenever you collect a gem?
Hi great tutorial I'm just wondering how do I make it so when you collect a number of items it brings you to a new scene like a game over scene.
Hi, thanks. You could add another script that contains a method that checks the number of items collected and then executes your desired action. Then you could wire up the collected event to this new method. Hope that helps 😊
@@KetraGames Is there any chance we could get some code written out for this method to check the number of items? I'm trying to do something similar but I keep getting an error saying that the playerInventory is non-invocable. Here's the code I've written below:
public class PhotoAppear : MonoBehaviour
{
PlayerInventory playerInventory = GetComponent();
void Start()
{
gameObject.SetActive(false);
}
// Update is called once per frame
public void Update()
{
if (playerInventory.NumberOfPhotos() == 5)
{
gameObject.SetActive(true);
}
return;
}
}
As well, thank you for this tutorial, what it covered was very easy to follow and understand.
Did you ever figure this out?@@spongehead93
How would you write that in code?@@KetraGames
Yes I'm looking for the same tutorial nobody has it😢😢
Goshh😭 thank you so much. I totally appreciate it.
👍😊
this was so clear and its recent. im subbing
Thank you 😊
Thank you for such a great guide! How would you carry the gem display onto another scene? I tried the same thing but nothing displayed
Hi, good question. There are a few ways you can pass data between scenes
1. You can use PlayerPrefs to save and load data between scenes - docs.unity3d.com/ScriptReference/PlayerPrefs.SetInt.html
2. Game Objects can survive between scenes if you set DontDestroyOnLoad so this may be a possibility - docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html
3. Another option is to store the data in a ScriptableObject which will then persist across scenes - docs.unity3d.com/Manual/class-ScriptableObject.html
Hope that helps 😊
@@KetraGames wow you didn't hold back i really appreciate this.. you are amazing! Keep up the great work !
Thanks for this tutorial ❤️❤️
👍😊
bruh I got an error something about it not containing a defintion
Same
Did you solve the problem?
Nice vid it works great on my own game
Thanks, good to hear this 😊
Lovely video! The only part I am wondering is how would I add a sound to when I collect a diamond?
Hi, to play a sound you need to have an audio source. Because the diamond is disabled when it's collected, it won't be able to play the sound itself. Therefore, you will need to add an audio source to the Player object. You can then play as sound using AudioSource.PlayOneShot - docs.unity3d.com/ScriptReference/AudioSource.PlayOneShot.html
Hope that helps 😊
@@KetraGames but it doesnt work if its collider other, how do you connect it? pls help unu
@@alejandraalcocer9857 @KetraGames and anyone else looking to add sound to these collectibles...I found a solution :) I made a tutorial here: ruclips.net/video/mA9UQwjykpk/видео.html ...basically just add a parent to your diamond and give that its own bigger collider, audio source, and the "Play Sound on Enter" script in the tutorial :)
Thanks for all the dope videos! 🙏 Keep it up, they are very helpful and everything is well explained, being a newb I dig that lol 😂
Thanks for this comment 😊
Hi.
can you show how to collect bullets, when the player press E with a canvas that shows the corrent amount of the bullets?
Simply Genius! Thx a lot!
Thanks fro this comment 😊
when i did it the dimond tex and image did't show on the screen
Thank you VERY MUCH for this video👍
👍😊
What simple anda wonderful tutorial right there, But I have question. So how to make value of the diamond collected to somewhat larger than 1?
Thanks 😊
If you wanted the diamond to increase the count by more than 1 you could change the line in the PlayerInventory. So rather than
NumberOfDiamonds++;
you could do
NumberOfDiamonds+= 10;
Hope that helps 😊
@@KetraGames it worked!!! Thank you very much
great tutorial!
Hello,
I have everything setup like in the video but when my character walks into the diamonds it does not collect them but they are solid instead and it just collides. It seems like a problem in my diamond script detecting player collision but everything is setup as in the video so I'm not sure what the issue is?
I had this problem a few minutes ago one child component in my diamond had a "collider" that didn't had "trigger" checked on.
please help me, I have followed the script but the diamonds don't disappear when they are taken 🙏🏻
Hi, does the diamond count on the screen go up even though they don't disappear? Are there any errors in the console?
@@KetraGames Hi ! I have the same problem than him, my character passes through the collectibles and it does send me an error 😢
And the « is Trigger » is clicked on so I really don’t know where the problem is coming from
@vmbrine You said it does send you an error? Could you send the details of the error if there is one.
Otherwise, it's a matter of debugging to see where the issue is. You can either put breakpoints in the code and step through if you know how to do that. Or you can add Debug.Log lines in to see where it gets to before it fails.
Great tutorial. I have encountered an issue however with the last step ... public UnityEvent OnPickUpCollected; is not exposed in the inspector even with adding [SerializeField]. From what I gather this is a unity bug, any thoughts on a work around?
Hi, I can't think of why it wouldn't be visible. Are you seeing any errors in the Console window?
If you still can't get it to work, try copying the script form here - dotnetfiddle.net/Rzs92c
Hope that helps 😊
@@KetraGames Thank you for the quick response! No errors in console. When researching this issue I found lots of posts claiming this was a unity bug issue with exposing unity events in the inspector. Some suggested you could get around this issue using [System.Serializable].
The example is: "I have found the way.
first you have to define your own event type (which is just a basic public class). however the custom event type must inherit from UnityEvent, like so."
[System.Serializable]
public class myFloatEvent : UnityEvent{}
"then you can make variables from it, like so."
[SerializeField]
public myFloatEvent onChangeEvent;
I'm just not sure how to refactor this to work with your example.
I've had a look into this and it seems this was an issue on earlier versions of Unity. What version are you using?
Hi thanks for the great tutorials. I'm getting the same error at this point also, i have the latest versions of unity and visual studio my character has [SerializedField] On a third person shooter controller. Not sure if this would have any effect?!🤷♂️
I followed the code all they way even copy and paste it but on the last step UpdateDiamondText did not show up
witch ipnut are u using old or new? its dowsnt work for me i havent errors on scripts bad my chr dsnt collect the diamonds
Hi, this is using the old input system. We're planning a video showing how to upgrade to the new system at some point in the future.
@@KetraGames cant wait for that thank you
Hello , i have 3 object to collect and what should i do to collect it in order if 1 is not collected 2 is collected,then of 1 is collected and 2 collected?
Another perfect tutorial by Ketra Games :) Thank you very much. May I ask a question: I've got two characters in the game but player can use both of them by swaping. I assigned the PlayerInventory script both of them and it works, BUT once the character#1 collects some diamonds and if I swap to the character#2 and collect any diamond then die diamond collection amount RESETS to 1.
It seems Unity or the script keeps the amount for each character seperately, which is fine btw, but
1st Question= how can I show the amount of diamond collection amount of each character on canvas seperately?
2nd Question = how can I show the total diamond collection amount (without resetting) on the same canvas / text area?
Many Thanks !
Hey, first of all i love your tutorials on unity, but i've been watching countless tutorials, blog posts and The unity guide and can't find anything about persistent collectable couter, how can i make it that when i collect 7 collectables in one level that i start the next one with 7?
Hi, you would need to persist this between scenes. There are several options to do this. You can use a static variable, Unity's Player Prefs, or you can serialise to disk and load it back in again. Hope that helps 😊
@@KetraGames hi i want that when i get to 10 diamonds the player go to next level scene 2, how i can make that happen?
How can I make an item spawn after collecting all objects (diamonds)
Hi, you would need to keep track of how many diamonds are left in the scene. You could write a script that gets the count of diamonds in the scene in the Awake method. Then subscribe to the diamond collected event and decrease this count each time. Once you reach zero you can initialise the object you want. Hope that helps 😊
@@KetraGames it's like i want an item to spawn at a certain location after a player collects 7 diamonds i made a parkour game that you can only win by collecting a special item but i want that item to only spawn when you collect a specific amount of gems .
I'm a beginner with no knowledge of coding but I'm halfway done with my game I'm making with just tutorial
Hi there! What if I want the diamonds to spawn randomly during the day?
This helped, thanks!
👍😊
@@KetraGames It still worked even though I wasn't using diamonds as the object.
@@KetraGames Do you know how to make it so that when all the items are collected, a scene changes or something?
@@shang_psycho7414 Hi, you would need to keep track of how many collectables are still active in the scene. Once you reach zero then you can trigger the scene change.
@@KetraGames Ok. If I can't figure out how to do that, I'll try something else. Thanks for the advice.
Amazing video!
At the very beginning: big hugs to you💚! You do wonderful tutorials for beginners, I learn a lot from your videos. Thank you!
I used this video to add scripts to an existing project that I have been working on for a while. I already have a canvas for Game Over.
I did what you did in this video, no bugs, player can collect diamonds but unfortunately nothing is charged on the canvas. I watched the tutorial again and I don't know where the error may be. I know it's hard to answer something "out of the head", but maybe someone has an idea?🙄
Hi, glad you're finding the videos useful. Have you set up the event handler in the Inspector to update the canvas when a diamond is collected? If so, it might be worth adding a Debug.Log line in the method you're calling from the event handler, to make sure it is getting called. Hope that helps 😊
4:25 //use override
When I walk over the "diamonds" they don't get collected :/ anyone know why?
Great tutorials. However im runing into an error with this one, even if i copy your code from the fiddle link.
ArgumentException: Object of type 'UnityEngine.Object' cannot be converted to type 'PlayerInventory'.
I get this error when i implement the last steps. Everything works fine up till then. The gems gets picked up and removed but at soon as i want to send the number of gems to the UI i get the error. And only when i attempt to pick up the gems.
Hi, can you check that when you trigger the event in the PlayerInventory script, that you're passing through 'this'
OnDiamondCollected.Invoke(this);
That should pass the PlayerInventory through to the UI script.
If that doesn't work you could try changing the event to just be a general event
public UnityEvent OnDiamondCollected;
Then when you wire up the event in the Inspector, there should be an extra slot for the PlayerInventory that you can drag the Player object into.
Hope that helps 😊
Great video...what if i want diamonds to be collected for example 20 and then congratulations on passing a level?
Hi, you would need to create another script to do this. You could still hook up the diamond collected event to this new script but check if the total has reached 20 before making the text visible. Hope that helps 😊
Hiya,
Thanks for the nice video, was easy to follow. Bit of a plot twist for me though - I'm using 2D so maybe that's the problem.
Basically I have a fireball that comes down and I want my character to collect it. The fireball has a rigidbody, circular collider and bouncy physics. When it hits my dragon it doesn't get collected - any ideas?
Hi, have you marked the collider as a trigger?
On Diamond Collected PlayerInventory the update name you said I cant find it. TextmeshProUGui.UpdateFontAsset is the one I can pick?
Hi, I'm not sure why it wouldn't be showing. Have you compared your script to the one here
dotnetfiddle.net/Rzs92c
HIIII! Amazing tutorial! Do you think this is doable on an AR game? I'm trying to figure out if there's any possibility to collect an AR element and put it into an inventory (ideally on click as it is an android app) yet I didn't manage to find any tutorial on this topic :( Any advice? Thanks!
Hi, sorry I've not looked into AR functionality in much detail. I'd have thought it was possible though
my fpc character just runs straight through the gems, i followed your code exactly and i cannot get it to work
Hi, do you see any errors in the console window?
How to move box collider?
Hi, the box collider position is linked to the transform of the object it is attached. You can change the center position to offset it however you want. Hope that helps 😊
Where to add this scripts in first person play ?!
great tutorial. can i request tutorial "trigger a dialog with npc"?
Thanks for the suggestion. We'll add it to the list of future videos 😊
Hi, I have a problem. I have all the scripts copied and put into the correct objects but there's something wrong. When I go to my character the Player Inventory script doesn't show the thing where I can select the function of OnDiamondCollected. Plus, when I try to test the game and grab the collectables it just throws me this error:
"NullReferenceException: Object reference not set to an instance of an object PlayerInventory.DiamondCollected () (at Assets/PlayerInventory.cs:13)
Diamond.OnTriggerEnter (UnityEngine.Collider other) (at Assets/Diamond.cs:13)"
By the way, I'm using Unity 2019.4.40f1 Personal. Maybe that has something to do? If you can help I'd thank you a lot.
how to collect the diamond in order like in diamond1 diamond 2 diamond 3 , if diamond 1 one is collected you cannot collect the diamond 2 and diamond 3.
Please help! This was an awesome tutorial, but I can't find 1 thing on the internet that explains how to load next scene if all objects are collected!!!
thanks
👍😊
Super helpful 🤩
Great to hear 😊
Thankyou so much.
👍😊
A beginner question, in the "InventoryUI" script,
why did you put argument for the "UpdateDiamondText" method?
What was the source of that argument to make the method work?
Thank you,
Hi, the UpdateDiamondText uses the PlayerInventory parameter to get the number of diamonds that have been collected.
playerInventory.NumberOfDiamonds.ToString();
This is passed through when the event is invoked from the PlayerInventory.
OnDiamondCollected.Invoke(this);
In this case 'this' refers to the PlayerInventory invoking the event.
Hope that makes sense 😊
@@KetraGames I see, thanks a lot
life savior
Great to hear 😊
Perfect! "thx you";
Thanks 😊
If you are looking to add sound to these collectibles where it plays once...I found a solution :) I made a tutorial here: ruclips.net/video/uazpON_0JdA/видео.html (Edited because the parent object sound didn't always work, and you couldn't keep it from playing anytime you entered the area even if collectable was gone).
...basically just add a sound object on top of the collectable... and give that its own collider, audio source, and the "Play Sound on Enter" script in the tutorial :) I got the sound script from @ChrisTutorialsYT ruclips.net/video/E7-HAJ4Db64/видео.html, then I added a bool for "if already played".
QUESTION:
Are the public class names just the name of the C# script. For example,
public class PlayerInventory : Monobehaviour;
because the filename is called PlayerInventory.
Hi, yes, usually the name of the file is the same as the name of the class.
Thank uu
👍😊
How we can spawn diamonds randomly on terrain, please help 😊
Hi, you could generate a navmesh for the walkable area of your terrain. Then you could find random points on the navmesh to place diamonds. This link may help answers.unity.com/questions/475066/how-to-get-a-random-point-on-navmesh.html
@@KetraGames Thank you for replying so quickly. Actually you know what, i am a total beginner and i have to submit my project after 2 days. So can you please make a quick video on this topic i am sure many us want a video on topic. Please
I had requested you to make tutorial on how we can access our collected coins from other scenes...
Hi, we've added it to the list to cover in a future video 👍
Thanksalot
a me non va