Ambiera ForumDiscussions, Help and Support. |
|
[ 1 2 ] Page 1 of 2 |
|
|||||
|
how you can clone a cube inside the game and be able to select it as for a strategic game |
||||
|
I don't quite understand what you mean by using it for a strategy game, but you can easily clone it using the function ccbCloneSceneNode. You can create a clone in a variable like this: var clone = ccbCloneSceneNode(nodeThatYouCloned); Then, you can perform any actions you want with this node. For more information on how to do this, could you provide more details about what exactly you need to do with this clone? |
||||
|
Normal cloning doesn't allow me to distinguish the cubes I clone. If I wanted to select cloned cubes, I would only select the original one and that's a problem. I just need an example on how to clone it and distinguish it |
||||
|
var cloneNodeCount = 0; var clone = ccbCloneSceneNode(nodeThatYouCloned); ccbSetSceneNodeProperty(clone, "Name", "name_" + cloneNodeCount); cloneNodeCount += 1; That allows you to define a different name for each cloned node, and then select it by the needed name. But you still need to provide more information. |
||||
|
of course the cubes must behave as units and this has already been done. I just have to clone them and put them in a specific point like a base so when I press the button to create the cube soldiers they are different and I can select them to give them the commands that I will then insert. Is it possible to also define a position after cloning? I'm using this but it doesn't work after cloning them var p = ccbGetSceneNodeFromName("cube"); ccbSetSceneNodePositionWithoutCollision(p, 39.016857, 22.383883, -12.144409); |
||||
|
You're using cbSetSceneNodePositionWithoutCollision, so you're using the "Collide when moved" behavior, right? Because if you're not, you should set the basic property by ccbSetSceneNodeProperty(clone, "Position", newPositionVector);
|
||||
|
But you still need to provide a better explanation of what this node is and how it's supposed to work. After that, I can give you a more complex example of code. |
||||
|
As explained, it is a cube soldier who attacks the player when he sees it but when I put time to clone him and this has already been done I would like the cube soldier to clone himself in a specific position and have the possibility of being selected to give him the commands problem is that with normal cloning I can't select the cubes because it only selects the original cloned cube. I need to be able to select the other cloned cubes |
||||
|
What method of node selection are you using? |
||||
|
a simple one I click on the cube I give it a variable and from there I let it do what I'm interested in, dock, move etc etc. all I need is that when it is cloned it can be distinct and different so that if I click on it and give it a command the other clones don't execute it. |
||||
|
Let's see. First of all, you said: click on the cube Are you using the default behavior of CopperCube, or did you write your own? Because with clones, it's better to write specific behavior. Next, you mentioned: I give it a variable and from there I let it do what I'm interested in Are you creating a variable based on the name of the exact clone, or is there some other way? For now, I see one solution based on what you've told me. When you create a clone, place it into a specific node as a child. Then, when you try to select something, use a for loop on click to search if the mouse hits each clone inside this parent node. This will allow you to get the needed clone, and then you can manipulate it as you wish. |
||||
|
that's right I'm using default commands with coppercube. Is there a way to do it in code? clone and make them different from each other? Thank you |
||||
|
Here's the pseudocode I wrote to illustrate the basic principle of what I'm talking about. It works well in the engine and demonstrates how to clone a node and select (get the node into a variable) a clone by clicking on it.
|
||||
|
So you can use the function 'cloneNode' to create a new clone and then call 'getSelectedNode' to retrieve one of these clones. |
||||
|
wow thanks ok but I know up to a certain point about javascript this works if I use the coppercube default function to click the cube which then does the javascript function where do I insert this? sorry and I'm trying to understand given my limited language |
[ 1 2 ] Page 1 of 2 |
|