{"record":{"id":"5273ae9cfa26599e","repo":"FyroxEngine/Fyrox","slug":"unable-to-apply-position-because-underlying-type","errorCode":null,"errorMessage":"Unable to apply position, because underlying type is not Vector2!","messagePattern":"Unable to apply position, because underlying type is not Vector2!","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"fyrox-ui/src/animation.rs","lineNumber":126,"sourceCode":"    }\n}\n\n/// Extension trait for [`BoundValueCollection`].\npub trait BoundValueCollectionExt {\n    /// Tries to set each value from the collection to the respective property (by binding) of the\n    /// given widget.\n    fn apply(&self, node_ref: &mut UiNode);\n}\n\nimpl BoundValueCollectionExt for BoundValueCollection {\n    fn apply(&self, node_ref: &mut UiNode) {\n        for bound_value in self.values.iter() {\n            match bound_value.binding {\n                ValueBinding::Position => {\n                    if let TrackValue::Vector2(v) = bound_value.value {\n                        node_ref.set_desired_local_position(v);\n                    } else {\n                        Log::err(\n                            \"Unable to apply position, because underlying type is not Vector2!\",\n                        )\n                    }\n                }\n                ValueBinding::Scale => Log::warn(\"Implement me!\"),\n                ValueBinding::Rotation => Log::warn(\"Implement me!\"),\n                ValueBinding::Property {\n                    name: ref property_name,\n                    value_type,\n                } => bound_value.apply_to_object(node_ref, property_name, value_type),\n            }\n        }\n    }\n}\n\n/// Animation player is a node that contains multiple animations. It updates and plays all the animations.\n/// The node could be a source of animations for animation blending state machines. To learn more about\n/// animations, see [`Animation`] docs.","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/FyroxEngine/Fyrox/blob/76c91aad8eca488ce527b1af707be8b3b24ad72d/fyrox-ui/src/animation.rs#L108-L144","documentation":"UiAnimation::apply maps animation track values to widget properties. The Position binding requires the track to hold Vector2 values; if the track holds any other value type, the engine cannot apply it and logs this error (no panic).","triggerScenarios":"An animation track bound to ValueBinding::Position whose TrackValue is not TrackValue::Vector2 (e.g. created with f32/bool values).","commonSituations":"Building UI animations programmatically and pushing wrong-typed keyframes into the position track; importing/retargeting animations between widgets with mismatched track types.","solutions":["Ensure Position tracks are created with TrackValue::Vector2 values","Verify the track's value type when constructing the animation","Add a match/guard on the TrackValue variant before binding to Position"],"exampleFix":"// before\ntrack.set_binding(ValueBinding::Position);\ntrack.add_value(TrackValue::Real(1.0));\n// after\ntrack.set_binding(ValueBinding::Position);\ntrack.add_value(TrackValue::Vector2(Vector2::new(10.0, 10.0)));","handlingStrategy":"type-guard","validationCode":"match track_value { TrackValue::Vector2(_) => apply_ok(), _ => fix_track_type() }","typeGuard":"fn is_vector2_track(v: &TrackValue) -> bool { matches!(v, TrackValue::Vector2(_)) }","tryCatchPattern":null,"preventionTips":["Create Position tracks only with Vector2 keyframes","Validate animation data when importing or building programmatically","Check binding/value pairing at animation construction time"],"tags":["ui","animation","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"76c91aad8eca488ce527b1af707be8b3b24ad72d","analyzedAt":"2026-09-10T16:04:01.633Z","contentChangedAt":"2026-09-10T16:04:01.633Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}