Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Change SceneNodeHeight

VeganPete
Guest
Quote
2021-04-02 16:48:12

Hi,

how would I change the height of a scene node every second using code please?

What I've done so far:

Every few seconds (1000ms)>change variable "SandHeight" = "SandHeight" +1

Every few seconds (1000ms)>execute javaScript:

var h = ccbGetSceneNodeFromName("RisingSand");
ccbSetSceneNodePositionWithoutCollision(h, 185.941574, SandHeight, -214.547958);

Obviously it doesn't work.

I do have a workaround for it but I'd like to learn a proper coding method instead.

Thanks.


just_in_case
Moderator
Quote
2021-04-02 17:48:13

What do you mean by changing height, do you mean change the position?
I think you wanted to change the scale of the object. There is an action "Scale Animated" that can do the job scale the object on "Y-axis " every few seconds.

It might give the effect as if the sand/water is raising up. Or you can always use change position of an object and use move by a vector on the positive of Y-axis. If you intended to change the position of the object.


just_in_case
Moderator
Quote
2021-04-02 17:58:55

Ooo so you want to change the position with coding only.


In the above code that you have written there is one slight mistake and that is you are using variable "sandheight" as a string and then adding 1 to it.

Just remove the quotation around the variables and it should work fine. You don't even need to define a variable sandheight you can directly increment the position on the Y-axis , and instead of using values for x,and z axis. You can get the current position and use that.

So your new code can be like this.



var h = ccbGetSceneNodeFromName("RisingSand");
var pos = ccbGetSceneNodeProperty(h,"Position");

ccbSetSceneNodePositionWithoutCollision(h, pos.x, pos.y +1, pos.z);



This should work fine, if it doesnt then there might be some typos as am on my mobile device and i make a lot of typos while texting from mobile.


veganpete
Registered User
Quote
2021-04-03 01:22:22

Thank you just_in_case - yes, I meant position, not height. I'll take a look at your code and try it. Really appreciate the help.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "In?ernational" (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