armory3d / armory

3D Engine with Blender Integration
https://armory3d.org/engine
zlib License
3.07k stars 316 forks source link

nodes based scripting appears to not respect value of Blender property set in Properties ->Custom Properties #2964

Closed Anniepoo closed 1 year ago

Anniepoo commented 1 year ago

Description When Krom starts custom Blender object property does not respect set value from properties panel as default

To Reproduce

  1. Start blender 3.6.5 with SDK23.10.0
  2. Follow the tutorial at https://www.youtube.com/watch?v=w0vQTVyGCyM to create a simple 1ps camera controller - I named this trait "OnePSLook"
  3. Create a custom property active_camera, type integer, and value 1 on the 'sphere' object
  4. Add a second trait "CameraSelect" to the 'sphere' object. Add a Keyboard node and Set Object Property that sets active_camera to 1 when the 1 key is pressed (needs an Integer node for the constant 1)
  5. Duplicate these nodes and change so typing "2" key changes active_camera to 2
  6. In OnePSLook add a Gate Node in the output of On Update node that only permits updates if active_camera is equal to 1
  7. Save file and run in Krom

Expected behavior Expect game to start in 1ps camera follows mouse mode. Observed: game starts with no camera motion. type 1 and camera action starts Behavior is fixed by adding On Init event that sets active_camera to 1

System Blender: 3.6.5 Armory: 23.10.0 OS: Ubuntu 22.04.1 LTS Gnome 42.5 Graphics card: NVIDIA Corporation TU106M [GeForce RTX 2060 Mobile] / Mesa Intel® UHD Graphics (CML GT2)

Test File (drag & drop the zipped .blend file here) starter.zip

This file includes the 'fix' - to repro bug, delete On Init and connected Set Object Property nodes

MoritzBrueckner commented 1 year ago

Hi, in your file there is a custom property called camera_select on the charactercollision object which is referenced by the CameraSelect trait, but the OnePSLook trait instead references the property active_camera which doesn't exist (thus, Get Object Property returns null). So I think there is no bug here.

Anniepoo commented 1 year ago

Thanks - new user error, and possibly "Get Object Property" being unclear if it means an Armory property or a Blender property.

MoritzBrueckner commented 1 year ago

Added some more documentation at https://github.com/armory3d/armory/commit/dcda14cac891fbd9507fec4816fab8fda97afd87 and implemented object property display for the debug console at https://github.com/armory3d/armory/pull/2965, maybe this helps to prevent issues like this in the future :)