ERROR: Attempted to set an object of type 'TextureRect' into a TypedArray, which does not inherit from 'CharacterBody2D'

Godot Version

4

Question

can some one tell me what this meens:
ERROR: Attempted to set an object of type ‘TextureRect’ into a TypedArray, which does not inherit from ‘CharacterBody2D’.
ERROR: core/variant/array.cpp:490 - Condition “!_p->typed.validate(value, “set”)” is true.
what does inherit from ‘CharacterBody2D’ meen
how do i fix it

I’ve never seen this error before, but I assume that you have a typed array, like

var typed_array: Array[CharacterBody2D] = []

somewhere. This means you can only add objects of class CharacterBody2D into the array, and you are trying to add an object of class TextureRect to the array instead.

1 Like