maxim.stjazhkin Posted March 3, 2021 Share Posted March 3, 2021 Hello. My SDK version: UNIGINE 2 Community 2.13.0.1 (GNU/Linux) I tried to make a tutorial "11. Implementing Game Logic and Using Properties" from " Programming quick start C++" of the official documentation and I got an error compiling the tutorial code. The output of my compiler is in attachment. After reading the documentation more closely, I found changes in working with properties. It looks like the tutorial was written for an earlier version of the SDK, or for a future one :) However, I made the following changes to the tutorial code, in file AppWorldLogic.cpp: /// function setting new object as selected and updating previous selection int selectObject(ObjectPtr new_selected_object, ObjectPtr &old_selected_object) { // checking if we already have the object selected previously if (old_selected_object == new_selected_object) return 0; // checking if we already have a previously selected object and setting its "selected" parameter of the property to 0 if (old_selected_object) { int property_id = old_selected_object->findProperty("my_node_base"); if (property_id >= 0) { PropertyPtr my_node_base = old_selected_object->getProperty(property_id); // ERROR: my_node_base->setParameterInt(my_node_base->findParameter("selected"), 0); my_node_base->getParameterPtr("selected")->setValue(0); } } // checking if new selected object is not NULL and it has a property with parameter "selected" assigned if (new_selected_object) { int property_id = new_selected_object->findProperty("my_node_base"); if (property_id >= 0) { PropertyPtr my_node_base = new_selected_object->getProperty(property_id); // ERROR: my_node_base->setParameterInt(my_node_base->findParameter("selected"), 1); my_node_base->getParameterPtr("selected")->setValue(1); old_selected_object = new_selected_object; } return 1; } return 0; } /// method updating the initial set of scene objects int AppWorldLogic::updateObjects() { ... // if "selected" parameter value is 0 assigning the material that is stored in the "material" parameter of its property // ERROR: object->setMaterial(p->getParameterString(p->findParameter("material")), "*"); object->setMaterial(p->getParameterPtr("material")->getValueString(), "*"); ... } After that, everything was successfully compiled, started and worked as described in the tutorial. Please check the source code of the tutorial and correct it, if necessary. Since such errors are a little discouraging for novice UNIGINE users, like me. Kind regards! compiler_output.txt Link to comment
maxim.stjazhkin Posted March 3, 2021 Author Share Posted March 3, 2021 Moderators, please move this topic into "Improving UNIGINE" -> "Documentation". Thanks a lot! Link to comment
thomalex Posted March 3, 2021 Share Posted March 3, 2021 Hello @maxim.stjazhkin, 4 hours ago, maxim.stjazhkin said: It looks like the tutorial was written for an earlier version of the SDK Indeed, the Property's API has slightly changed, thank you for noticing and sorry for the inconvenience caused. The source code will be thoroughly revised and updated in the upcoming release. Thank you! 1 Link to comment
Recommended Posts