How to Pass Values b/w two objects. Let say if 2+3 is one object then its answer is 5 is another object. So need to pass value 5 to another object in the scene. How to achieve this task in Buildbox 3D?
Hi,you cannot pass values in buildbox for two objects but how ever you can achieve by some technique. i .e set an session points as 5 in event observer on an UI .Now add button with value 2 as an action with 2 points and other button as 3 points.Now when user clicks first button 2 points would be awarded similarly for the other button.Now session points turn 5 and it would navigate to next UI .How ever there is a catch If at any cost session points is greater than 5 then it would still go to next UI even if its a wrong answer . So in simple you can't add it without programmatically .
First, the BB3 API document is here: http://download.buildbox.com/buildbox/assets/documentation/api.html#buildbox-scene-find-name It is a must read. Second, some terminology (as I understand it). A .bbdoc files holds a game. A game has scenes. A game has a library. A library has objects. A scene has entities. When you drop an object into a scene, it gives the scene a new entity. A scene has nodes. Entities have components. ANSWER 1... Passing information between 2 entities: In entity called FROM... let TO_entitiy_arr = this.scene().find("TO"); // find returns an array holding all the entitities with the name given. In this case "TO" if ( TO_entity_arr[0] ) { // get a reference to the component containing the function I want to call to pass the info let the_comp = TO_entity_arr[0].component("Script"); // call a function the_comp.holiday("Halloween candy is best"); } In entity called TO ... A component called Script function holiday(holiday_str) { // log the information passed TO me, to prove it got here. log(holiday_str); } // Automatically, the variable "component" points to THIS component that the software is in. // The next statement attaches the function called holiday to this component // so it's "visible" from other components.. meaning anything that has a reference to The Script component of the TO entity // can call this function component.holiday = holiday; ANSWER 1... Passing information between 2 components in the same entity.. Connect the 2 components. The output of the FROM to the input of the TO. You may have to add an output. Click little "+" on output side of the FROM component. (must have the little marker or crayon icon in upper right of the component. That means you can edit the component.) Name the output, for example.. "Holiday" Select Number when you add the output port. Inside the FROM, you use the command like so... this.emitSignal("Holiday", 2); Inside the TO, the info will arrive via the function signal(name, value ) { if ( name == "Holiday" ) { if ( value == 2 ) log("Halloween candy is best"); } } // signal Now.. you are probably asking yourself... A) Why on earth isn't "String" one of the choices for the type of port to add? Got me hanging. Because I don't know the answer to B) B) Hey? This is javascript. What the heck are we doing specifying variable TYPEs at all? The call to this.emitSignal( ) should take any type of variable in either parameter. In fact, there's no javascript reason why emitSignal / signal is limited to 2 parameters / arguments. (pro tip: Looks to me emitSignal is not an async function call, as one might expect. ) MAYBE.. type of Object is meant to be the workaround for emitting strings. Which would be fine, but... BUT.. at the time of this writing, "Object" type output and input *do* *not* *work* properly (Script component to Script component) No matter what object I emit, the only thing that arrives into the signal function is {x:0, y:0, z:0}. No fun at all, yet.
@gauravdashora676 Oops you were asking for BB3 ? I didn't see it .I thought its for BB2 . Thanks @DanFarfan
Yep, my question too. I wanted a string as an attribute and I'd never noticed that it wasn't in the dropdown. I made a request but haven't heard anything. You can get around this by using a component's signal function to pass objects between components and it works, as I describe in this thread: https://www.buildbox.com/forum/inde...s-objects-between-nodes-on-same-object.13881/
@LBPToo We can't able to find Sring options for add but they added this internally for one of their node's parameter. I have done a small trick. I just copied that node (Which already having String parameter) and moved my javascript code ( SKExplosion code's Asset Name). https://www.buildbox.com/forum/index.php?threads/actor-explosion-bbasset.14008/.
Thanks @particles. Good find. I just checked it out and that's exactly what I needed. This makes me wonder even more why String isn't one of the options in the Add Attribute list.