ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Programming and Scripting
forum topic indicator How to get the position of a scene node and then move another scene node to that position
person icon
spicymilk
Registered User
Quote
2023-06-06 15:54:48

yep

person icon
Guest
Guest
Quote
2023-06-06 18:00:41

https://www.ambiera.com/coppercu...

person icon
jaimezegpi
Registered User
Quote
2023-06-13 15:20:13

This ??

//------------------
var a = ccbGetSceneNodeFromName("scene_node");

if ( a ){
var a_pos = ccbGetSceneNodeProperty(a, "Position");
}


var b = ccbGetSceneNodeFromName("another_scene_node");

if( b ){
var b_pos = ccbGetSceneNodeProperty(b, "Position");
}

if( a && b ){
ccbAICommand(b, "moveto", new vector3d(a_pos.x,a_pos.y,a_pos.z));
}

//------------------

person icon
dev
Registered User
Quote
2023-06-21 20:22:50

Thanks I'll check those out

person icon
Dieter
Guest
Quote
2023-08-21 10:17:20

Or you could simply set the position:

var a_pos = ccbGetSceneNodeProperty(node1, "Position");
ccbSetSceneNodeProperty(node2, a_pos);

There is also a command to set position and ignore collision:
var s = ccbGetSceneNodeFromName("cubeMesh1");
ccbSetSceneNodePositionWithoutCollision(s, -22.097015, 9.848448, -40.738777);

Also keep in mind, if node1 is parented to something, better use "PositionAbs" as Property name to get the real position.

person icon
Dieter
Guest
Quote
2023-08-21 10:20:25

Uh sorry, there's a bug in my above script, it should be:

var a_pos = ccbGetSceneNodeProperty(node1, "Position");
ccbSetSceneNodeProperty(node2, "Position", a_pos);


Create reply:










 

  

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


icon_holyicon_cryicon_devilicon_lookicon_grinicon_kissicon_monkeyicon_hmpf
icon_sadicon_happyicon_smileicon_uhicon_blink   






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