🌍 Get the Polygon Fantasy Pack cmonkey.co/synty_fantasykindgom_hydroneer 🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses 🔴 RELATED VIDEOS 🔴 How to Pick up and Drop Objects/Items! (First and Third Person) th-cam.com/video/2IhzPTS4av4/w-d-xo.html How it's Made: How Mechanics and System from various Games work th-cam.com/play/PLzDRvYVwl53ttN_5uyfqs3nnOn0Jd4s92.html Remaking 3 Great Mechanics from Cyberpunk 2077! th-cam.com/video/pIzWlfbVORU/w-d-xo.html Kickstart your game with First and Third Person Controllers! (FREE Unity Starter Assets) th-cam.com/video/jXz5b_9z0Bc/w-d-xo.html Crafting Items with Scriptable Objects! th-cam.com/video/E91NYvDqsy8/w-d-xo.html Make your Games Designer Friendly! (Scriptable Objects) th-cam.com/video/7jxS8HIny3Q/w-d-xo.html Place UI Elements in your World! (Health Bar, Overlays, Timers) th-cam.com/video/Zwgj3mwOVlg/w-d-xo.html
@@aaronjenkins2225 I agree, Aaron. One of the tenants of accessibility is to create simpler interactions. This is great for that! Thanks Code Monkey and Hydroneer!
I love this series - to see how someone would implement something and how different ideas one has for the architecture of the mechanic. Really refreshing after days spend in your own code One thing I suggest is avoiding nested ifs; as much as it's logical to have one condition after another it's way readable to invert the logic, Even if it's something simple, there's a chance it might grow; nesting layers and layers of ifs makes it problematic after time to know where you are; inversing the logic will simplify it, by letting you "forget" about certain conditions; fe. instead: if (foo) { if (bar) { // do something } } you can do: if (!foo) return; if (!bar) return; //do something The code works the same, but instead going deeper bracket after bracket, you eliminate the possibilities on your way down the code; this works esspecially well when you keep your code clean and make seperate methods for functionalities
If you found Hydroneer UX interesting, I suggest having a look at Astroneer. There's no on-screen UI (except for main menu, settings). There are only a few UI elements but they are all displayed on in-game objects. The resources aren't just a slot in an inventory with a number on it, but physical objects that can be moved around by the player. Every interaction from the player is done in the game world.
CodeMonkey, I think you are reaching your highest potential so far. These videos are high quality and go beyond basics. Do more explanation in the future like climbing(or jumping over stuff), advanced cover system(like in GTA), simple procedural 2D dungeons and etc.
super neat system! one tip: you can just have List.Remove as the conditional as it returns a bool if the remove was successful, instead of checking if it contains and then remove.. :) thanks for great content!
at 9:05 there is a mistake - it should be `placeItemsAreaBoxCollider.transform.position + placeItemsAreaBoxCollider.center` instead of `transform.position + placeItemsAreaBoxCollider.center` it doesn't matter if the pivot points of the anvil and the crafting area are the same, but if you move it for the crafting area, you'd be spending a bunch of time debugging trying to figure out why it no longer detects collisions.
ItemSO script: using System.Collections; using System.Collections.Generic; using UnityEngine; [CreateAssetMenu()] public class ItemSO : ScriptableObject { public Sprite sprite; public string name; public Transform prefab; }
It really do be like that. At first I was intimidated by making an inventory or crafting etc. now all that is trivial to me and I should learn shaders soon, I thought it wouldn't be that hard and I could just use shader graph but then I watched a couple videos on video game grass and realized shader graph isn't even a viable option.
It wouldn't exactly simplify much since you still need to get the component. It would reduce the amount of colliders that it hits and improve performance slightly, however Layers are limited to only 32 so if you use the layer method you need to be careful to not have too many types of layers.
First off Thanks for another awesome tutorial! I HAVE LEARNED SO MUCH FROM YOU! THANK YOU! But ive been trying to implement a functionality of zooming the item in and out. I could really use your help as IM stumped on how to get the item to UPDATE over the original position. I have been able to increment it and/or decrease it, but it always snaps back to the original position. AS well, depending on which direction one is looking, the X axis, Is now the wrong way.. If you could please do a video addon to this one? Showing how to zoom the item IN and OUT once grabbed? Or, any advice or help would be greatly appreciated! THANKS! :D
Zooming in or out would be a case of moving it closer or further from the camera. The item always goes to that position in front of the camera, so you just need to move that position closer/farther from the camera. You can move it using the mainCamera.transform.forward vector
Hi! where do u missed sth? Cuz while everything goin brilliant there's one issue.. even if in recipe it requires 2 stone to craft thing, it only takes one and still craft it
Thanks for amazing tutorial! Have you played the very old game Arx Fatalis? There's an interesting magic system. Could you make a tutorial on how to make a similar system for drawing and recognizing runes?
Haven't played it but apparently it's similar to Black and White where you draw the shape of the spells, that could be an interesting project to research, thanks for the suggestion!
Can you please explain what to do in the class ItemSO ? And also do you attach a script to every object, and gather ItemSO variable from it ? Thanks you :)
It's just a scriptable object holding data for that item, like the prefab and icon unitycodemonkey.com/video.php?v=7jxS8HIny3Q Yes usually the SO has a reference to the prefab and in the spawned object I usually have a reference to the SO where it came from
what's code monkey great work , wanted to know if can do a How it's made on the reticle (crosshairs) / entire UI form armored core 6 , using cinemachine virtual cams and the new input system, the aiming target lock effects and so forth? Thanks keep up the great work!
@@CodeMonkeyUnity ok, yeah I'm trying to use it with this robot characters pack and both hands are weapons sort of like mega man but both hands, and thinking about how to make it mobile compatible as well using ultimate joystick asset ,.. but yeah looking forward to what's next
hey man i love your tutorials! but i have a question. i use the coding engine called scratch that uses block coding and puts it in a simple form. is there anything like that for unity. kinda like bolt on unity but simpler?
Yes Unity has Visual Scripting unitycodemonkey.com/video.php?v=8y6akNTUt2Y I made a full course where I built 3 complete games all entirely with Visual Scripting without a single line of code unitycodemonkey.com/video.php?v=qAkeCDWgPVA
Hmm technically you could make the Craft function sort of recursive, so it calls the function, then if something is crafted it continues calling itself until there's nothing else to craft
Would it be a viable option to use raycast, detect the anvil, activate the collider, craft item and then disable the collider. In order to skip the possible collisionbox calculation error? Or is that a worse approach?
Technically that could work, not entirely sure if OnTriggerEnter would be called if you just enable a game object with objects already inside it However that sounds like a needlessly convoluted approach, sounds much simpler to do just a OverlapBox();
Hey Code Monkey! Awesome tutorial. I just think you should stop using old input system and start using the new input system. Don't spread the deprecated approaches 😉
The legacy input manager is not deprecated, it's still excellent for its simplicity. If I were making a full game I would still use the legacy input manager during development and only refactor to the new input system in the end, just like I did in my TBS course.
hi @Code Monkey! Amazing stuff here! Are there some project files for this tutorial? And if there are non, i would gladly pay for them on patreon or anywhere..
This one used tons of assets so I didn't make the project files for it, however the core of this system is just the picking up logic which I did make project files unitycodemonkey.com/video.php?v=2IhzPTS4av4 You can see the code on screen in this video and add it onto that one
me again :) i was trying to recreate this system in the past monts but my lack of knowelege faild to do it. You explained stuff in the video but some of them are not explained and how to connect all of them. I reaaly like this tutorial, it will be really great to put another video about it with full tutorial or post a github repo without graphics. Tnx again for all of your work!@@CodeMonkeyUnity
@@CodeMonkeyUnity I'm sure you can figure it out by watching Mark Brown's video on it BUT you take your time. I truly don't want to impose. Just hoping it's something that you think might be worth creating content for
Hi, I don't understand what RecipeSO objects consist of and what to put in the output. The script does not execute anything further than Debug.Log(Craft), and inputItemList is always 2
public void Craft() { Collider[] colliderArray = Physics.OverlapBox( transform.position + placeItemsAreaBoxCollider.center, placeItemsAreaBoxCollider.size, placeItemsAreaBoxCollider.transform.rotation); foreach (Collider collider in colliderArray) { Debug.Log(collider); } } } this dont work, but function correctly made
Hi I am currently making a mobile game and wanted to add levels using scriptable objects to change things like player position, how many coins they could collect etc… how would you go about this? Thanks
You can place the level environment in a prefab and instantiate that. Then maybe store a position for the player and list of positions for the coins, or include them as game objects in the level prefab
I was wondering if you could tell me what scripts I need to have in my game before I follow this video, I have already added a pickup and drop objects system from your How to Pick up and Drop Objects/Items! video, I am wondering what else I need to have before I can follow your video. You show the Crafting Anvil script, Crafting Recipe SO Script, and Player Crafting Script which I was able to write from the few glimpses you show of them within the first few minutes, but you don't show the Item SO script or Item SO Holder script which is needed to have them all work. I also don't know what objects and other stuff I would need to add to be able to use this tutorial. If you can, please copy the scripts and let me know what stuff I need to add to my game to add the crafting system from this tutorial. Thank you, and sorry about the long comment. I just really like you tutorials and really want to implement this crafting system into my survival game that I have been making.
Also I am getting the error "PlayerCrafting.cs(21,39): error CS0122:'CraftingAnvil.NextRecipe()' is inaccessible due to its protection level" My script is: using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerCrafting : MonoBehaviour { [SerializeField] private Transform playerCameraTransform; [SerializeField] private LayerMask interactLayerMask; private void Update() { if (Input.GetKeyDown(KeyCode.E) || Input.GetMouseButtonDown(0)) { float interactDistance = 3f; if (Physics.Raycast(playerCameraTransform.position, playerCameraTransform.forward, out RaycastHit raycastHit, interactDistance, interactLayerMask)) { if (raycastHit.transform.TryGetComponent(out CraftingAnvil craftingAnvil)) { //Interacting with Crafting Anvil if (Input.GetKeyDown(KeyCode.E)) { craftingAnvil.NextRecipe(); // This is the line that is giving me the error } if (Input.GetMouseButtonDown(0)) { craftingAnvil.Craft(); } } } } } } Please help!!!! Once again the line is: craftingAnvil.NextRecipe();
The ItemSO is just a scriptable Object definition, I did something like that in this video unitycodemonkey.com/video.php?v=E91NYvDqsy8 And the ItemSOHolder just has a field of ItemSO, that component is attached to the item prefab so the prefab knows what item type it is. This is mostly a standalone tutorial, it's not part of a course so there's no step by step video on how every system was made unitycodemonkey.com/video.php?v=PcArjIC1QnQ What you should take away from this tutorial is how the physics functions works, not necessarily the specifics for how the demo is setup, it is very likely that your own game is set up in a very different way from the demo so you can't just copy paste code, you need to adapt it to match whatever item system you have in your game.
Hi! Amazing video, but can you help me with this, please? I have a problem with the Place Items Area box collider, i setup everything exactly like you did, the code is the same and the empty object's box collider is the same. When i press the button to make the Craft code, the box collider of Place Items Area empy object detects EVERY object on the scene, everyone. By changing the ".size" to ".extents" or ".extents / 2", it detects everyobject directly touching my anvil, but it ignores every object inside the Place Items Area box collider. Its strange, it just seems to detect wherever he wants but not in the right area. I dont know what could be wrong, but if you can help me really thank you!
@@CodeMonkeyUnity All objects have colliders. I dont know if this may be the problem but your center of the Place Items Area box collider are values like “0.0018391” in x, y and z, while mine are 0 on every axis.
If you're looking for Visual Scripting then the VS course unitycodemonkey.com/video.php?v=qAkeCDWgPVA If you're looking for C# the Builder Defender course unitycodemonkey.com/video.php?v=cIuxrFYKZXI But for the absolute basics you can also just watch regular videos unitycodemonkey.com/video.php?v=E6A4WvsDeLE unitycodemonkey.com/video.php?v=IFayQioG71A unitycodemonkey.com/video.php?v=PcArjIC1QnQ
7:56 Wow! This is sooooooo WRONG! transform.TransformPoint(center) will include rotations and scale, also size should be scaled, but I'm not sure how at the moment.
@@CodeMonkeyUnity I mean you should. If that script parent gameobject gets rotated those position/scale/rotation will be wrong. It doesn't matter that it shouldn't happen. It's easy to use that objects transform.TransformPoint and so on, just to be sure that they always are correct. When I saw that line it was like a red flag to me that it is wrong. I've been doing a lot of such conversions lately and learned that you shouldn't just add those positions, they may not work if an object is rotated, and it will happen some when and that person will be debugging it after following your tutorial.
The problem is... You say that for this we should have watched the crafting system videos and stuff... But most of those videos are working on those specific methods of crafting and not much of it is actually on what we need for this tutorial... This is way too hard to follow
You need to learn how to adapt what you see in a tutorial to fit your needs, you will never find a tutorial that perfectly does exactly the very specific game you have in your mind. Don't just blindly copy past, instead learn the concepts behind why the tutorial works and adapt it to your specific use case.
@@CodeMonkeyUnitysure.. but two things apply to some people. First, not everyone learns like that. I pearn by seeing a finished product and then finding out how that works. Like in maths, Ill often use some kind of online calculator to give me the answer then I can find the method.,. And two. I get that I have to adapt some tutorials for others, but, I do this for fun in whatever little time I have after school and whatever I can do weekends. And there is not always the time to look through one or more hours of code tutorials to nitpick specific parts. I like the tutorials from you and have used a fair few (and learned quite a lot) but this one it pushing the realm of easy to follow. (Don't get me wrong though, it is still an amazing tutorial for those who can figure out the last few videos of content.
What you just described is the perfectly normal learning process. No one starts off with knowledge, you gain knowledge over time. Remember that I've been making games for 10 years and programming for 25. If you're a relative beginner then it's perfectly natural that it takes a while to learn something new. Just keep at it and over time you will learn more and more.
Hi there, I got 2 errors hope you could reply to me and tell me on how to fix these :) Assets\FPS_Movement_Rigidbody-master\CraftingRecipeSO.cs(9,17): error CS0246: The type or namespace name 'ItemSO' could not be found (are you missing a using directive or an assembly reference?) Assets\FPS_Movement_Rigidbody-master\CraftingRecipeSO.cs(10,12): error CS0246: The type or namespace name 'ItemSO' could not be found (are you missing a using directive or an assembly reference?) Script: using System.Collections; using System.Collections.Generic; using UnityEngine; [CreateAssetMenu(fileName = "NewCraftingRecipe", menuName = "CraftingRecipe")] public class CraftingRecipeSO : ScriptableObject { public Sprite sprite; public List inputItemSOList; public ItemSO outputItemSO; // Corrected typo here }
Thanks for the great video CodeMonkey! I have an issue where I cannot access the prefab when instantiating the item that is to be crafted. Any ideea what I am missing or doing wrong? It is in this line: Transform spawnedItemTransform = Instantiate( craftingRecipeSO.outputItemSO.prefab, itemSpawnPoint.position, itemSpawnPoint.rotation); // prefab here is underlined with red and says it is missing a definition. I think something is missing in my ItemSO.cs script.
Ok my bad, I was missing my prefab definition in the ItemSO script. public Transform prefab; Thanks again for all the hard work and I wish you great success going forward!
🌍 Get the Polygon Fantasy Pack cmonkey.co/synty_fantasykindgom_hydroneer
🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses
🔴 RELATED VIDEOS 🔴
How to Pick up and Drop Objects/Items! (First and Third Person) th-cam.com/video/2IhzPTS4av4/w-d-xo.html
How it's Made: How Mechanics and System from various Games work th-cam.com/play/PLzDRvYVwl53ttN_5uyfqs3nnOn0Jd4s92.html
Remaking 3 Great Mechanics from Cyberpunk 2077! th-cam.com/video/pIzWlfbVORU/w-d-xo.html
Kickstart your game with First and Third Person Controllers! (FREE Unity Starter Assets) th-cam.com/video/jXz5b_9z0Bc/w-d-xo.html
Crafting Items with Scriptable Objects! th-cam.com/video/E91NYvDqsy8/w-d-xo.html
Make your Games Designer Friendly! (Scriptable Objects) th-cam.com/video/7jxS8HIny3Q/w-d-xo.html
Place UI Elements in your World! (Health Bar, Overlays, Timers) th-cam.com/video/Zwgj3mwOVlg/w-d-xo.html
Hydroneer dev here! Thanks for being inspired by our game to make a tutorial video on the crafting system :) Great video
Hey! Thanks for making a great game, I really enjoyed playing it!
And congrats on the massive success!
Cool. Now when do we all get togeather and have a beer?
Lets game it out Agrees
This crafting system is genius, I'm very tempted to use something similar in my game project too. ☺️
@@aaronjenkins2225 I agree, Aaron. One of the tenants of accessibility is to create simpler interactions. This is great for that! Thanks Code Monkey and Hydroneer!
I love this series - to see how someone would implement something and how different ideas one has for the architecture of the mechanic. Really refreshing after days spend in your own code
One thing I suggest is avoiding nested ifs; as much as it's logical to have one condition after another it's way readable to invert the logic,
Even if it's something simple, there's a chance it might grow; nesting layers and layers of ifs makes it problematic after time to know where you are; inversing the logic will simplify it, by letting you "forget" about certain conditions;
fe. instead:
if (foo)
{
if (bar)
{
// do something
}
}
you can do:
if (!foo)
return;
if (!bar)
return;
//do something
The code works the same, but instead going deeper bracket after bracket, you eliminate the possibilities on your way down the code; this works esspecially well when you keep your code clean and make seperate methods for functionalities
Great suggestion, these are referred to as "Guard Clauses" for anyone wanting to search for more information on this paradigm.
If you found Hydroneer UX interesting, I suggest having a look at Astroneer.
There's no on-screen UI (except for main menu, settings). There are only a few UI elements but they are all displayed on in-game objects. The resources aren't just a slot in an inventory with a number on it, but physical objects that can be moved around by the player. Every interaction from the player is done in the game world.
I was going to do some morning study learning some web stuff, but then I ended up watching this whole video, great video lol 😀
heh nice! This is a fun system!
CodeMonkey, I think you are reaching your highest potential so far. These videos are high quality and go beyond basics. Do more explanation in the future like climbing(or jumping over stuff), advanced cover system(like in GTA), simple procedural 2D dungeons and etc.
If you wanted to use the physics object, you can turn it off when its not needed and have the craft() turn it on.
List Remove returns a bool and true if the item was removed, so you can use that instead of the additional Contains check ;)
Oh I didn't actually know it returned a bool! I always used it as a statement, never in an if.
Goes to show you learn something new every day!
I didn't know it returned a bool either, thanks for sharing :P
using the collider for the positions but disabling it is a neat little trick.
super neat system! one tip: you can just have List.Remove as the conditional as it returns a bool if the remove was successful, instead of checking if it contains and then remove.. :)
thanks for great content!
How do i work this Remove function into the scripts?
Didn't know this game you were inspired by and this mechanic made me interested in try it.. thanks for teaching us
It's amazing, thanks! More about crafting, please! 😀
Thank you for your tutorial. I had to figure out the recipes and item scriptable objects but other than that it worked perfectly. thank you
can you Post them please ?
Super useful tutorial, love the series! Keep it up ❤
Would you consider making a similar tutorial for an Overwatch-like character controller?
at 9:05 there is a mistake - it should be
`placeItemsAreaBoxCollider.transform.position + placeItemsAreaBoxCollider.center`
instead of
`transform.position + placeItemsAreaBoxCollider.center`
it doesn't matter if the pivot points of the anvil and the crafting area are the same, but if you move it for the crafting area, you'd be spending a bunch of time debugging trying to figure out why it no longer detects collisions.
ItemSO script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu()]
public class ItemSO : ScriptableObject
{
public Sprite sprite;
public string name;
public Transform prefab;
}
The more I advance in programming, the more I feel like a beginner
You never stop learning
It really do be like that. At first I was intimidated by making an inventory or crafting etc. now all that is trivial to me and I should learn shaders soon, I thought it wouldn't be that hard and I could just use shader graph but then I watched a couple videos on video game grass and realized shader graph isn't even a viable option.
There's always more to learn!
Good, but i think if you was made the special Physic Layer for collisions of Anvil and Items for making receipts, it can simplify the code?
It wouldn't exactly simplify much since you still need to get the component. It would reduce the amount of colliders that it hits and improve performance slightly, however Layers are limited to only 32 so if you use the layer method you need to be careful to not have too many types of layers.
First off Thanks for another awesome tutorial! I HAVE LEARNED SO MUCH FROM YOU! THANK YOU! But ive been trying to implement a functionality of zooming the item in and out. I could really use your help as IM stumped on how to get the item to UPDATE over the original position. I have been able to increment it and/or decrease it, but it always snaps back to the original position. AS well, depending on which direction one is looking, the X axis, Is now the wrong way.. If you could please do a video addon to this one? Showing how to zoom the item IN and OUT once grabbed? Or, any advice or help would be greatly appreciated! THANKS! :D
Zooming in or out would be a case of moving it closer or further from the camera.
The item always goes to that position in front of the camera, so you just need to move that position closer/farther from the camera. You can move it using the mainCamera.transform.forward vector
Hi! where do u missed sth? Cuz while everything goin brilliant there's one issue.. even if in recipe it requires 2 stone to craft thing, it only takes one and still craft it
Love your content and the way you teach!
I'm glad to hear that! Thanks!
Hey I want to know how it is made the disassembly and assembly in my summer car plz
Really nice tutorial! Thank you for sharing!
Thanks for amazing tutorial!
Have you played the very old game Arx Fatalis? There's an interesting magic system. Could you make a tutorial on how to make a similar system for drawing and recognizing runes?
Haven't played it but apparently it's similar to Black and White where you draw the shape of the spells, that could be an interesting project to research, thanks for the suggestion!
Cool series!
Can you please explain what to do in the class ItemSO ? And also do you attach a script to every object, and gather ItemSO variable from it ? Thanks you :)
It's just a scriptable object holding data for that item, like the prefab and icon unitycodemonkey.com/video.php?v=7jxS8HIny3Q
Yes usually the SO has a reference to the prefab and in the spawned object I usually have a reference to the SO where it came from
i got a code monkey ad in a code monkey vid
XD
Just an observation but the world canvas is still a UI element.
this is really good stuff.
what's code monkey great work , wanted to know if can do a How it's made on the reticle (crosshairs) / entire UI form armored core 6 , using cinemachine virtual cams and the new input system, the aiming target lock effects and so forth? Thanks keep up the great work!
I haven't played it yet so not sure but I have on my to-do list to make a video covering Cinemachine 3.0 which changed quite a lot of things
@@CodeMonkeyUnity ok, yeah I'm trying to use it with this robot characters pack and both hands are weapons sort of like mega man but both hands, and thinking about how to make it mobile compatible as well using ultimate joystick asset ,.. but yeah looking forward to what's next
nice work
You are awesome sir! Thank you!
hey man i love your tutorials! but i have a question. i use the coding engine called scratch that uses block coding and puts it in a simple form. is there anything like that for unity. kinda like bolt on unity but simpler?
Yes Unity has Visual Scripting unitycodemonkey.com/video.php?v=8y6akNTUt2Y
I made a full course where I built 3 complete games all entirely with Visual Scripting without a single line of code unitycodemonkey.com/video.php?v=qAkeCDWgPVA
@@CodeMonkeyUnity oh wow thank you so much man it helps alot :D
Would you be able to place 4 iron ingots and craft 2 daggers with just one craft input?
Hmm technically you could make the Craft function sort of recursive, so it calls the function, then if something is crafted it continues calling itself until there's nothing else to craft
Would it be a viable option to use raycast, detect the anvil, activate the collider, craft item and then disable the collider. In order to skip the possible collisionbox calculation error? Or is that a worse approach?
Technically that could work, not entirely sure if OnTriggerEnter would be called if you just enable a game object with objects already inside it
However that sounds like a needlessly convoluted approach, sounds much simpler to do just a OverlapBox();
Hey Code Monkey! Awesome tutorial. I just think you should stop using old input system and start using the new input system. Don't spread the deprecated approaches 😉
The legacy input manager is not deprecated, it's still excellent for its simplicity. If I were making a full game I would still use the legacy input manager during development and only refactor to the new input system in the end, just like I did in my TBS course.
Thanks mr Code Monkey!
hi @Code Monkey! Amazing stuff here! Are there some project files for this tutorial? And if there are non, i would gladly pay for them on patreon or anywhere..
This one used tons of assets so I didn't make the project files for it, however the core of this system is just the picking up logic which I did make project files unitycodemonkey.com/video.php?v=2IhzPTS4av4
You can see the code on screen in this video and add it onto that one
me again :) i was trying to recreate this system in the past monts but my lack of knowelege faild to do it. You explained stuff in the video but some of them are not explained and how to connect all of them. I reaaly like this tutorial, it will be really great to put another video about it with full tutorial or post a github repo without graphics. Tnx again for all of your work!@@CodeMonkeyUnity
Still hoping for the Snake Pass snake movement that no TH-camr has dared do before...
Perhaps a certain Monkey can show us how a snake can move..? :D
th-cam.com/video/4NNPr2Ay4OM/w-d-xo.html is a good starting point for now.
@@snook5555that IS where I started. Actually, I think that might have been where I even heard of snake pass :D
I've heard great things about it but haven't played it yet, need to find the time!
@@CodeMonkeyUnity I'm sure you can figure it out by watching Mark Brown's video on it BUT you take your time. I truly don't want to impose. Just hoping it's something that you think might be worth creating content for
help, the crafted Item Instatiates when the Items are placed on the Anvil but the Crafting Items wont destroy....
Add some Debug.Log to see what your code is doing, are you cycling through all the items?
You are amazing
Hi, I don't understand what RecipeSO objects consist of and what to put in the output.
The script does not execute anything further than Debug.Log(Craft), and inputItemList is always 2
public void Craft() {
Collider[] colliderArray = Physics.OverlapBox(
transform.position + placeItemsAreaBoxCollider.center,
placeItemsAreaBoxCollider.size,
placeItemsAreaBoxCollider.transform.rotation);
foreach (Collider collider in colliderArray) {
Debug.Log(collider);
}
}
}
this dont work, but function correctly made
please, i need unity package for analiyze my code and CodeMonkey code and find the error
I FOUND THE ANSWER!! The collider of anvil nnot on a anvil
That one is a scriptable object, it just holds data unitycodemonkey.com/video.php?v=7jxS8HIny3Q
Hello, what is the package of the environment from 17:03?
That's the game Hydroneer, not sure if they used assets or if they are original
@@CodeMonkeyUnity thanks, its look like synty studio assets
Hi I am currently making a mobile game and wanted to add levels using scriptable objects to change things like player position, how many coins they could collect etc… how would you go about this? Thanks
You can place the level environment in a prefab and instantiate that. Then maybe store a position for the player and list of positions for the coins, or include them as game objects in the level prefab
Thanks will try
Amazing!
moves like dagger
do you have any comment about the gigaya?
I covered it in this video unitycodemonkey.com/video.php?v=HobK9kug-Lo
7:45 Physics.OverlapBox ought to take a box collider as an argument. Why give the user the opportunity to get confused on world-vs-local positioning?
That would be a nice addition! The function already has tons of versions so adding one more for a BoxCollider input would be a nice small improvement
From where I can get the ItemSO script
All the code is shown in the video so you can just write it yourself, it's a simple scriptable object.
I was wondering if you could tell me what scripts I need to have in my game before I follow this video, I have already added a pickup and drop objects system from your How to Pick up and Drop Objects/Items! video, I am wondering what else I need to have before I can follow your video. You show the Crafting Anvil script, Crafting Recipe SO Script, and Player Crafting Script which I was able to write from the few glimpses you show of them within the first few minutes, but you don't show the Item SO script or Item SO Holder script which is needed to have them all work. I also don't know what objects and other stuff I would need to add to be able to use this tutorial. If you can, please copy the scripts and let me know what stuff I need to add to my game to add the crafting system from this tutorial. Thank you, and sorry about the long comment. I just really like you tutorials and really want to implement this crafting system into my survival game that I have been making.
Also I am getting the error "PlayerCrafting.cs(21,39): error CS0122:'CraftingAnvil.NextRecipe()' is inaccessible due to its protection level"
My script is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerCrafting : MonoBehaviour
{
[SerializeField] private Transform playerCameraTransform;
[SerializeField] private LayerMask interactLayerMask;
private void Update()
{
if (Input.GetKeyDown(KeyCode.E) || Input.GetMouseButtonDown(0))
{
float interactDistance = 3f;
if (Physics.Raycast(playerCameraTransform.position, playerCameraTransform.forward, out RaycastHit raycastHit, interactDistance, interactLayerMask))
{
if (raycastHit.transform.TryGetComponent(out CraftingAnvil craftingAnvil))
{ //Interacting with Crafting Anvil
if (Input.GetKeyDown(KeyCode.E))
{
craftingAnvil.NextRecipe(); // This is the line that is giving me the error
}
if (Input.GetMouseButtonDown(0))
{
craftingAnvil.Craft();
}
}
}
}
}
}
Please help!!!! Once again the line is:
craftingAnvil.NextRecipe();
The ItemSO is just a scriptable Object definition, I did something like that in this video unitycodemonkey.com/video.php?v=E91NYvDqsy8
And the ItemSOHolder just has a field of ItemSO, that component is attached to the item prefab so the prefab knows what item type it is.
This is mostly a standalone tutorial, it's not part of a course so there's no step by step video on how every system was made unitycodemonkey.com/video.php?v=PcArjIC1QnQ
What you should take away from this tutorial is how the physics functions works, not necessarily the specifics for how the demo is setup, it is very likely that your own game is set up in a very different way from the demo so you can't just copy paste code, you need to adapt it to match whatever item system you have in your game.
You probably made NextRecipe(); private instead of public
@@CodeMonkeyUnity Okay, Thank you
@@CodeMonkeyUnity Thank you, that was the problem. I fixed that and the error went away.
Hi! Amazing video, but can you help me with this, please?
I have a problem with the Place Items Area box collider, i setup everything exactly like you did, the code is the same and the empty object's box collider is the same. When i press the button to make the Craft code, the box collider of Place Items Area empy object detects EVERY object on the scene, everyone. By changing the ".size" to ".extents" or ".extents / 2", it detects everyobject directly touching my anvil, but it ignores every object inside the Place Items Area box collider. Its strange, it just seems to detect wherever he wants but not in the right area. I dont know what could be wrong, but if you can help me really thank you!
Do your objects have a collider?
Only thing I can think of is maybe you're using a weird position, add a Debug.Log to see what values you're using
@@CodeMonkeyUnity All objects have colliders. I dont know if this may be the problem but your center of the Place Items Area box collider are values like “0.0018391” in x, y and z, while mine are 0 on every axis.
May I ask what is the code inside ItemSO?
It's just a scriptable object unitycodemonkey.com/video.php?v=7jxS8HIny3Q
It holds a Transform prefab, a Sprite and a string name
@@CodeMonkeyUnity Ahh okay, thank you so much
Hello again, the game gave me an error from this line of code:
List ingredientsList = new List(recipeSO.ingredientsSO);
Same, did you ever find a fix to this?
@@conorasf3418 Nope
@@imdublin4431 I figured it out, it was because I did not implement the next recipe function . In that function is where he initializes the list
public void NextRecipe()
{
Debug.Log("nextRecipe called");
if (craftingRecipeSO == null)
{
craftingRecipeSO = craftingRecipeSOList[0];
}
else
{
int index = craftingRecipeSOList.IndexOf(craftingRecipeSO);
index = (index + 1) % craftingRecipeSOList.Count;
craftingRecipeSO = craftingRecipeSOList[index];
}
When will you do a multiplayer tutorial ? #1
The Netcode for Game Objects comes out of preview
What happen to the gold? It turn into silver?
Magic crafting!
@@CodeMonkeyUnity Thanks Code Monkey
please can you make a full 3rd person shooter controller
I did unitycodemonkey.com/video.php?v=FbM4CkqtOuA
hey,code monkey,went to your website to enroll but its confusing for me,which course is the first one to take for beginners? I'm just stupid
If you're looking for Visual Scripting then the VS course unitycodemonkey.com/video.php?v=qAkeCDWgPVA
If you're looking for C# the Builder Defender course unitycodemonkey.com/video.php?v=cIuxrFYKZXI
But for the absolute basics you can also just watch regular videos
unitycodemonkey.com/video.php?v=E6A4WvsDeLE
unitycodemonkey.com/video.php?v=IFayQioG71A
unitycodemonkey.com/video.php?v=PcArjIC1QnQ
@@CodeMonkeyUnity thank you so much
7:56 Wow! This is sooooooo WRONG! transform.TransformPoint(center) will include rotations and scale, also size should be scaled, but I'm not sure how at the moment.
Uh? What is wrong? I'm not using TransformPoint(); anywhere
@@CodeMonkeyUnity I mean you should. If that script parent gameobject gets rotated those position/scale/rotation will be wrong. It doesn't matter that it shouldn't happen. It's easy to use that objects transform.TransformPoint and so on, just to be sure that they always are correct. When I saw that line it was like a red flag to me that it is wrong. I've been doing a lot of such conversions lately and learned that you shouldn't just add those positions, they may not work if an object is rotated, and it will happen some when and that person will be debugging it after following your tutorial.
The problem is... You say that for this we should have watched the crafting system videos and stuff... But most of those videos are working on those specific methods of crafting and not much of it is actually on what we need for this tutorial... This is way too hard to follow
You need to learn how to adapt what you see in a tutorial to fit your needs, you will never find a tutorial that perfectly does exactly the very specific game you have in your mind.
Don't just blindly copy past, instead learn the concepts behind why the tutorial works and adapt it to your specific use case.
@@CodeMonkeyUnitysure.. but two things apply to some people. First, not everyone learns like that. I pearn by seeing a finished product and then finding out how that works. Like in maths, Ill often use some kind of online calculator to give me the answer then I can find the method.,. And two. I get that I have to adapt some tutorials for others, but, I do this for fun in whatever little time I have after school and whatever I can do weekends. And there is not always the time to look through one or more hours of code tutorials to nitpick specific parts.
I like the tutorials from you and have used a fair few (and learned quite a lot) but this one it pushing the realm of easy to follow.
(Don't get me wrong though, it is still an amazing tutorial for those who can figure out the last few videos of content.
What you just described is the perfectly normal learning process. No one starts off with knowledge, you gain knowledge over time. Remember that I've been making games for 10 years and programming for 25. If you're a relative beginner then it's perfectly natural that it takes a while to learn something new. Just keep at it and over time you will learn more and more.
First
Hi there, I got 2 errors hope you could reply to me and tell me on how to fix these :)
Assets\FPS_Movement_Rigidbody-master\CraftingRecipeSO.cs(9,17): error CS0246: The type or namespace name 'ItemSO' could not be found (are you missing a using directive or an assembly reference?)
Assets\FPS_Movement_Rigidbody-master\CraftingRecipeSO.cs(10,12): error CS0246: The type or namespace name 'ItemSO' could not be found (are you missing a using directive or an assembly reference?)
Script: using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "NewCraftingRecipe", menuName = "CraftingRecipe")]
public class CraftingRecipeSO : ScriptableObject
{
public Sprite sprite;
public List inputItemSOList;
public ItemSO outputItemSO; // Corrected typo here
}
That means you don't have any class named ItemSO
@@CodeMonkeyUnity TYSM! I never thought you would reply tho, also forgot to comment about this tutorial, it waas awesome!
Thanks for the great video CodeMonkey! I have an issue where I cannot access the prefab when instantiating the item that is to be crafted. Any ideea what I am missing or doing wrong? It is in this line: Transform spawnedItemTransform = Instantiate(
craftingRecipeSO.outputItemSO.prefab,
itemSpawnPoint.position,
itemSpawnPoint.rotation); // prefab here is underlined with red and says it is missing a definition. I think something is missing in my ItemSO.cs script.
Ok my bad, I was missing my prefab definition in the ItemSO script. public Transform prefab; Thanks again for all the hard work and I wish you great success going forward!
I'm glad you found the solution, thanks for the kind words!