FyroxEngine/Fyrox · error
Animation: unable to set value of type
Error message
Animation: unable to set value of type {}! Types mismatch! What it means
Animation value bindings set typed values through Box<dyn Any>. The set function downcasts the target any-value to type T and, on failure, logs 'Animation: unable to set value of type {}! Types mismatch!' and returns false instead of panicking. It means the bound property's runtime type does not match the type the animation curve produces.
Solutions
- Make the track's value type match the property's type (use TrackValueKind / correct generic parameter when building the track).
- Verify the target node's property type in the editor before binding the track.
- Check apply_to_any's return/false result and log which property path is mismatched, then fix the track definition.
Example fix
// before
let mut track = Track::new(0, TrackValueKind::Real32); // f32
track.set_target_property("Position"); // Vector3 property
// after
let mut track = Track::new(0, TrackValueKind::Vector3);
track.set_target_property("Position"); Defensive patterns
Strategy: validation
Validate before calling
assert_eq!(track.value_kind(), target_property_kind(path)); // kinds must match
Prevention
- Match TrackValueKind to the target property's type
- Re-create tracks when property types change during refactors
When it happens
Trigger: Binding an animation track whose produced value type (e.g. f32, Vector3<f32>) differs from the property it is applied to — e.g. animating a Vector3 property with an f32 curve or vice versa via ValueBinding::apply_to_any.
Common situations: Editor animation created against one node type then reused on another; refactor changed a property's type (f32 -> f64, Vector2 -> Vector3); scripts manually constructing tracks with mismatched element types.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Failed to set property
- Unable to use material property
- Unable to use texture binding
- Unable to apply position, because underlying type is not…
- Implement me!
AI-assisted analysis of FyroxEngine/Fyrox@76c91aad8e (2026-09-10).
Data as JSON: /api/errors/a92e9124c2f608ac.
Report an issue: GitHub.
Appendix: source
Thrown at fyrox-animation/src/value.rs:267
}
fn convert_vec4<T>(vec4: &Vector4<f32>) -> Vector4<T>
where
f32: AsPrimitive<T>,
T: Copy + 'static,
{
Vector4::new(vec4.x.as_(), vec4.y.as_(), vec4.z.as_(), vec4.w.as_())
}
fn set<T>(any: &mut dyn Any, value: T) -> bool
where
T: Any + Copy,
{
if let Some(any_val) = any.downcast_mut::<T>() {
*any_val = value;
true
} else {
Log::err(format!(
"Animation: unable to set value of type {}! Types mismatch!",
any::type_name::<T>()
));
false
}
}
match self {
TrackValue::Real(real) => match value_type {
ValueType::Bool => set(any, real.ne(&0.0)),
ValueType::F32 => set(any, *real),
ValueType::F64 => set(any, *real as f64),
ValueType::U64 => set(any, *real as u64),
ValueType::I64 => set(any, *real as i64),
ValueType::U32 => set(any, *real as u32),
ValueType::I32 => set(any, *real as i32),
ValueType::U16 => set(any, *real as u16),
ValueType::I16 => set(any, *real as i16),View on GitHub (pinned to 76c91aad8e)