Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Thanks. :-) The pathfinding extension works using the pathnodes generated by  5v3n extension https://5v3n.itch.io/coppercube-new-pathfinder-plugin    and a Breath-First algorithm.

If you want to used it, it's this way  

1) You will need to generate the pathnodes and their connections using that extension.
2) Once you have the txt file with all connections (by default it creates it as 'Lvl1.txt' i think) you have to load it inside a var when the scene starts. 

3)You can trigger the extension 'NPC Pathfinding' from anywhere (character or other things in the scene), in the extension's property 'NPC' is to indicate the character's scene node  and in 'ConnectionsVar' you indicate the name of the var from step 2.

4) 'StartNodeVar'  Optional, indicate the node (the little cubes the 5v3n script generates) from where the NPC starts walking, or leave it blank to automatically calculate the closes one. You have to put the node's name inside a var, do not use the node's name directly. 

5)  'EndNodeVar' as before, inside a variable indicate the destination node where the NPC should go.  If 'RandomizeEnd' is true, it ignore it and just choose a random node to go.

6) 'RandomRange' is a little range variation from node to node. Basically IRL when people walk to a place, you don't just walk in a perfect straight line (specially in long walks), you deviate a little from the path, to one side and to the other. So this is to mimic that very same deviations.

7) 'ActionWhenFinished' Optional, There you assign any action to execute once the NPC reach it's destination (starting another loop, spawing enemies, changing an animation,  anything).  If empty, the NPC just stop.


Sorry for the wall of text. Hope it's clear. 


:-)

nice, but how do you put the nodes name inside a variable and how do you load the Lvl.1txt inside a variable too

In coppercube's documentation there is a Javascript reference glossary: https://www.ambiera.com/coppercube/doc/index.html

But basically, once you created the txt file using 5v3n plugin you can use 'ccbReadFileContent(filename)' to load the file and 

'ccbSetCopperCubeVariable(varname, value)' to send them into a var. something like this: 

ccbSetCopperCubeVariable("nodes",ccbReadFileContent("Lvl1.txt"));

You may need to first create the coppercube variable in the engine doing a 'When scene load' -> 'set or change a variable'

(IDK how is in english, i have coppercube in Spanish).


Is one of the very first thing the game does. The .ccb is inside the folder in case you wanna check it out. Sorry i didn't documented it.

Now i think about it, i have an extension for an action that does that exact thing. I don't have it at hand right now, but i can share it later.

ok, thanks a lot, i'm looking forward to the extension

Here, simply create a js file with this:

/*
<action jsname="action_send_txt_file_to_var" description="Read a txt file and send it to a variable">
<property name="Filename" type="string" default="Filename.txt" description="Enter the Filemname to be entered"/>
<property name="Variable_Name" type="string" default="" description="Enter the name of variable to be loaded"/>
</action>

*/

action_send_txt_file_to_var = function () {

};

action_send_txt_file_to_var.prototype.execute = function (currentNode)
{

ccbSetCopperCubeVariable(this.Variable_Name,ccbReadFileContent(this.Filename));

};

You can either use this script or what i said ' ccbSetCopperCubeVariable("nodes",ccbReadFileContent("Lvl1.txt"));' inside the action 'execute a javascript' 

Don't be afraid to ask me anything else. :-) lucks.

thank you for being responsive and welcoming

what about the path nodes name to put in StartNodeVar and EndNodeVar, how do you put those nodes into a variable

You are welcome pal. :-)

To be clear. You don't put the nodes as is in the variables, you put the names of the nodes either by doing a  'ccbSetCopperCubeVariable(varname, value)' or by using the action 'Set or change a variable'. 

So if you wanna move a character to a node named "chair", you either do a ccbSetCopperCubeVariable("end_node", "chair") or a 'Set or change a variable' -> VariableName = 'end_node' , operation = 'Set (=)' , ValueType = 'Value' , Value = 'chair'

Now I get it, thank you so much

Also, this pathfinding action is so good, i was thinking why dont you expand it to an enemy action,to make enemies look smarter, that would be a plus, what do you say  :)

Thanks, though I can't take the credit. I made it with ChatGPT.

:-/

And honestly, why don't I create an enemy action or behavior from there? Well, for one thing, it didn't occur to me, haha. For another, there are many types of enemies that work differently: soldiers who take cover, zombies, blind monsters that react to sound, paranormal entities, a math teacher, etc.

Need help making a specific enemy? I can’t promise anything, and I’m busy with an asset pack, but I can try to give you a hand.

:-)