Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Get a node's width ? possible

CopperGuy221
Guest
Quote
2023-05-28 13:46:46

Hi everyone,

I would like to know , is it possible to get an animated node(my player) width ?

I tried something like this but it returns false:

var player = ccbGetSceneNodeFromName("player");

var playerWidth= ccbGetSceneNodeProperty(player, "Width (pixels)");

print('player width is '+playerWidth);

Does soemone have I idea please?


sven
Registered User
Quote
2023-05-28 13:53:44

How about scale? ScaleX scaleY scaleZ


CopperGuy221
Guest
Quote
2023-05-28 14:04:25

it doesn't work with scale also unfortunately.

I tried and still return false:

var player = ccbGetSceneNodeFromName("player");

var playerWidth= ccbGetSceneNodeProperty(player, "ScaleX");

print('player width is '+playerWidth);


sven
Registered User
Quote
2023-05-28 14:34:38

var playerScale= ccbGetSceneNodeProperty(player, "Scale");
print(playerScale.x);
print(playerScale.y);
print(playerScale.z);


CopperGuy221
Guest
Quote
2023-05-28 14:45:36

I works but I don't think it is what I need.
I wanted the player width so that I can move the player in a direction by adding or removin the player width from his PosX

here with scale I wont work


just_in_case
Moderator
Quote
2023-05-28 15:42:17

HI, unfortunately there is no command to get actual width of any 3D object directly in CopperCube. But here is a workaround to get width of any object.

In your 3D scene create a cubemesh with size of 1, attach this cubemesh to the object whose width you want to get by attaching I mean make it children of that object, and change the position to (0,0,0) for the cubemesh. Now the cubemesh will be in the center of your object. Now change the cubemesh material to either transparent or Transparent add, when I said make it transparent I mean also apply a transparent texture to it.
Now start scaling the cubemesh to the width and height of your object and that's it.

Now, whenever you want to get the width of your object, simply try to get the scale of that cubemesh on the axis that you want to get the width of either X or Z axis and you will have the exact width of your object, it doesn't matter wether it's animated or static.

just make sure when you create cubemesh it is of size 1.
I also showcased this in one of my YouTube video, but people generally don't notice these tricks in my videos.

One can also use the polygon editing API,but that will computationally heavy and won't work with animated objects.

Hope this helps you and anybody who needs to achieve the same


Robbo
Guest
Quote
2023-05-29 07:31:50

I think you need something like this plugin:

https://robo25.itch.io/coppercube-editor-mesh-size

it will measure the absolute size of any mesh in CopperCube regardless of scale applied.


Robbo
Guest
Quote
2023-05-29 07:32:57

Actually only works for static mesh - not animated...


Aiming_bullets
Guest
Quote
2023-05-29 07:36:16

@Robbo, also it won't work if collision is off for the object.


CopperGuy221
Guest
Quote
2023-05-29 10:08:27

Thanks everyone for your answers. I'm gonna try them all and come back to tell you.




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© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact