Alright so the previous version had an empty slot for the requirement level TMPro UGUI, but it was missing. I created my own and got it to work. Apart from that, this system works quite well (if I bump into any weird bugs, I’ll update you), but I still hope we can have a skill tree dedicated for crafting, smithing, woodcutting, mining, fishing, etc (I coded a simple woodcutting and mining system on my own, I don’t mind sharing it)… I’ll probs come up with an entire skillset for an RPG-Style game for different needs. I have strong belief it will want to make the player play the game more, because now he has different skills to train. @bixarrio and @brian_trotter thank you both so so much for carrying me this far with my wild project ideas… (I’m not gone yet, but a simple thank you and appreciation might be nice from my behalf, at least for the moment !)
Frankly speaking though @bixarrio , your code is very very clean, and this makes it very easy to understand what’s going on
BTW if anyone reading this needs the code to get the Player to get close to the crafting table first, replace your ‘HandleRaycast()’ method with this one:
public bool HandleRaycast(PlayerController callingController)
{
// If there are no recipes, no interaction with the crafting table allowed
if (recipes == null || recipes.Length == 0) return false;
if (Input.GetMouseButtonDown(0))
{
// Distance between the Players' Calling controller (i.e: the player), and the Crafting table position
float distanceToCraftingTable = Vector3.Distance(transform.position, callingController.transform.position);
if (distanceToCraftingTable > acceptanceRadius)
{
// If you are far from the table, move towards it first
callingController.GetComponent<Mover>().MoveTo(transform.position, 1.0f);
isMovingTowardsCraftingTable = true;
// If you are moving towards the table and you're close to it, don't get closer, start crafting
if (isMovingTowardsCraftingTable && distanceToCraftingTable <= acceptanceRadius)
{
isMovingTowardsCraftingTable = false;
CraftingActivated?.Invoke(recipes);
}
return true;
}
else if (distanceToCraftingTable <= acceptanceRadius)
{
// If you're close to the table, start crafting, don't get any closer
CraftingActivated?.Invoke(recipes);
isMovingTowardsCraftingTable = false;
return true;
}
}
if (isMovingTowardsCraftingTable && Vector3.Distance(transform.position, callingController.transform.position) <= acceptanceRadius)
{
// If you're close, start crafting. Don't get any closer
CraftingActivated?.Invoke(recipes);
isMovingTowardsCraftingTable = false;
return true;
}
return true;
}
It’s a tad bit sloppy, where you need to move your mouse around a bit when you arrive to get it to work, but I’m still trying to fine tune it to get it to work properly
And add these two new variables:
// Accepted distance from Crafting table:
private float acceptanceRadius;
// Is the player moving towards the crafting table...?
private bool isMovingTowardsCraftingTable = false;
and if needed, initialize your ‘acceptanceRadius’ variable in your ‘Awake()’ method as follows:
void Awake() {
acceptanceRadius = 3.0f;
}
Edit: @Brian_Trotter can we please have this section re-opened? It got shut down before we finish it off