Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I'm having difficulties getting the current node's name from within an action. How can this be fixed? Thanks for any help. /* |
||||
|
@hadoken ccbGetCurrentNode()only works in execute javascript action. To get the current node in the action you can simply use "currentNode" so your action will look like this. If you want you can use 'currentNode' directly to get the property, you don't have to define it as a variable. /* you can use this to print the name of the current scene node. |
||||
|
@just_in_case Thank you very much for the fixed action script which delivers the correct current scene node name triggered by a built-in "When a key is pressed do something" behavior. Is there any possibility to also retrieve the current node triggered by the built-in "Every few seconds do something" behavior which is giving me an "Could not get property, provided scene node is invalid." error so far resulting in "current name=false" ?
|
||||
|
the above script should work fine with every behavior. I tried it myself with the every few seconds behavior and set time MS as "1" lowest possible and it worked for me. crosscheck if you had made any changes to the above script. |
||||
|
You are right - in fact it's working very well now, I just accidentally deleted the most important line in the header: <property name="Node" type="scenenode" default="" /> Sorry for the false alarm & many thanks @just_in_case, you're the best! Besides, if your times allows could you maybe also have another look at my javascript-"wait" issue from my last post at: https://ambiera.com/forum.php?t=... ? THX |
||||
|
yes you can use the below code to set the timer. this.startTime = (new Date()).getTime(); //start the timer insert the above code into your script where you want to trigger the timer to get started. Generally in the key pressed events. then you need to add this bit of code into your "onAnimate" section in your behavior or by registering an onframevent using the command ccbRegisterOnFrameEvent().
this will set the timer according to the time provided when the code is executed on keypresses. and then it compares it with the time going on each frame and then if the time on each frame is greater than the time stored when the key was pressed then it will execute the code provided. hope you understand it. |
|