Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Feature requests and bug reports
Instance/Node Variables

srfstudio
Registered User
Quote
2019-01-26 18:03:00

I'm not sure why the engine lacks instance/node variables but it would really enhance the level of functionality when it comes to accessing/cloning nodes data.

At the moment I was able to make use of 'Special Variables' feature but giving the 'Game Actor with Health' behavior to any node that requires node-specific variable is a bit unpractical.

I would really like to see this feature introduced in some of the following Coppercube versions, I believe it would be a very big step when it comes to node-related functionality.


ishmaru
Registered User
Quote
2019-01-27 05:35:02

I found this work around, use dynamically created copercube variables.


// Use this at the begining of the behavior to initialize variable
if(!this.nodeName){
this.nodeName = ccbGetSceneNodeProperty(node, "Name");
ccbSetCopperCubeVariable(this.nodeName + "VariableName", aStartingValue);
}


// To get variable from another script simply:
var otherNodeName = ccbGetSceneNodeProperty(InsertNodeHere, "Name");
ccbGetCopperCubeVariable(this.nodeName + "VariableName");


When cloning the nodes I recommend using JS to rename the cloned nodes using an incrementing coppercube variable that increases after each clone, to make sure each node has a unique name.


srfstudio
Registered User
Quote
2019-01-27 13:53:24

Damn never thought of dynamically creating variables based on node names, that's much more elegant solution, cheers!
Since I was using 'AI for Melee Combat' behavior I had 'Game Actor with Health's movementspeed var cleared :)
This was my take:
var node = ccbGetCurrentNode();
var nodename = ccbGetSceneNodeProperty(node, "Name");
var node_speed = "HASHTAG"+nodename+".movementspeed";
var node_speed_var = ccbGetCopperCubeVariable(node_speed);

var node_speed_str = (''+node_speed_var);

var node_armor_numb = node_speed_str.slice(0, 2);
var node_sword_numb = node_speed_str.slice(2, 3);
var node_shield_numb = node_speed_str.slice(3, 4);

var node_armor_var = parseInt(node_armor_numb, 10);
var node_sword_var = parseInt(node_sword_numb, 10);
var node_shield_var = parseInt(node_shield_numb, 10);
...first two numbers are armor, third number is sword, fourth number shield :) I'ts working but your solution is much simpler.


ishmaru
Registered User
Quote
2019-01-27 15:47:17

Not to mention easier to decipher. :)


srfstudio
Registered User
Quote
2019-01-27 18:55:32

Code worked out but, unfortunately, every enemy i clone is dead :)

If I change the clone's name he seem to lose health/damage values & appear in his dead-state/animation :)
var sourceNP1 = ccbGetSceneNodeFromName("enemyAA");
var nameadd_var = ccbGetCopperCubeVariable("nameadd");
var nameadd_value = nameadd_var + 1;
var newname = "enemy" + nameadd_value;

var spot = ccbGetSceneNodeFromName("BattleS1No1enemy2");
var newspot = ccbGetSceneNodeProperty(spot, "Position");

var newscenenode1 = ccbCloneSceneNode(sourceNP1);
ccbSetSceneNodeProperty(newscenenode1,"Name", newname );
ccbSetSceneNodePositionWithoutCollision(newscenenode1, newspot.x, newspot.y, newspot.z);
////////// Edit
...no, this seems to be working now, I'm not sure why it didn't work first couple of tries, I must of done something wrong with the code before :/


ishmaru
Guest
Quote
2019-01-27 20:01:57

In terms of the code above that looks good, though it seems to be missing the dynamic variables we talked about before. Not sure if this is intentional or not. It's hard to fully grasp what's going on without seeing all the code or even the sceen.

Can you answer some questions so I can get a better idea?

1 Are you using coppercube character behavior for health or does your script handle this?

2 similarly what is controlling your animations?

3 What node is the above script running on? The original node, or a separate node entirely?

4 is there any other script running that my be overlapping functionality? Like animation or movement?


srfstudio
Registered User
Quote
2019-01-27 20:14:57

The code is working now, I'm not really sure why it is working now or why it didn't work before :/ I did a big amount of changes left & right in my scripts, hopefully it will stay working or I will figure out what change I've made that was beneficial :)

Thank you again for your help, cheers!


ishmaru
Registered User
Quote
2019-01-28 03:44:27

NP, glad to help!


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internationa?" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact