Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name: Password:
Ambiera Forum > CopperCube > Programming and Scripting
Trouble with getting child node
Author Text

dekon_17
Registered User
Quote
2022-05-08 15:59:14

A while ago I made a thread there with the problem of my custom shooting (this is solved by now, so, don't need to check that). As I mentioned there, I made it in order to use hitboxes instead of collision... sphere? Ellipsoid? I don't know.
The thing is that after I did this, I've needed to heavily edit my old spawn script. Now, there's the problem: it can't properly find the child node, which is a folder.
🔎︎

	for (var i = 0; i < ChildCount; ++i);
{
var Folder = ccbGetChildSceneNode (Node, i);
var Hitbox = ccbGetChildSceneNode (Folder, 0);
ccbSetSceneNodeProperty (Hitbox, "Name", NewName + "HB" + i);
}

I think it might happen because it maybe can't use folders for that, yet it shown that the number of child nodes is 17 (which is how it is supposed to be). Did I done something incorrectly?

Also, if this isn't enough, there's full code, it doesn't work (for me) anyway because of this issue:
/*
<action jsname = "action_BSGSpawn" description = "Spawn enemies in BSG">
<property name = "Enemy" type = "scenenode"/>
<property name = "SpawnNodeName" type = "string" default = "Spawn"/>
</action>
*/

action_BSGSpawn = function()
{
};

action_BSGSpawn.prototype.execute = function()
{
var Fine = true;
var PosArray = [];
var RotArray = [];

for (var be = 0; Fine == true; ++be)
{
var Node = ccbGetSceneNodeFromName (this.SpawnNodeName + be)
if (Node)
{
PosArray.push (ccbGetSceneNodeProperty (Node, "PositionAbs"));
RotArray.push (ccbGetSceneNodeProperty (Node, "Rotation"));
}
else
var Fine = false;
}

for (var ni = 0; ni < PosArray.length; ++ni)
{
var Node = ccbCloneSceneNode (this.Enemy);
var Name = ccbGetSceneNodeProperty (Node, "Name");

for (var s = 0; Fine == false; ++s)
{
var New = ccbGetSceneNodeFromName (Name + s);
if (New)
{
}
else
{
var NewName = Name + s;
var Fine = true;
}
}

ccbSetSceneNodeProperty (Node, "Name", NewName);

var ChildCount = ccbGetSceneNodeChildCount (Node);
for (var i = 0; i < ChildCount; ++i);
{
var Folder = ccbGetChildSceneNode (Node, i);
var Hitbox = ccbGetChildSceneNode (Folder, 0);
ccbSetSceneNodeProperty (Hitbox, "Name", NewName + "HB" + i);
}

var NewPos = PosArray [ni];
ccbSetSceneNodePositionWithoutCollision (Node, NewPos.x, NewPos.y, NewPos.z);

var NewRot = RotArray [ni];
ccbSetSceneNodeProperty (Node, "Rotation", NewRot);
};
}



dekon_17
Registered User
Quote
2022-05-08 18:34:57

Okay, I think the reason might be in a loop construction because it works kinda fine without the for-loop (but returns only one hitbox, obviously).

[Edit: nevermind, I found the issue. This is a ridiculous mistake...]
for (var i = 0; i < ChildCount; ++i); //NICE



Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internati?nal" (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© 2020 Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact