ambiera logo

Ambiera Forum

Discussions, Help and Support.

folder icon Ambiera Forum > CopperCube > Programming and Scripting
forum topic indicator Get a node's width ? possible
person icon
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?

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

How about scale? ScaleX scaleY scaleZ

person icon
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);

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

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

person icon
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

person icon
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 sameemoji icon_holy

person icon
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.

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

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

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

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

person icon
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.

emoji icon_smile


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 |