Godot Version
4.1
Question
so im currently working on a pac-man remake and im making the ghosts, im currently at making the colors of the ghosts, but im having a problem
in the gd file for the ghost’s body, there is an error in this line of code:
func _ready():
self.modulate = (get_parent() as Ghost).color
the error identifier says its an error because the “Value of type “CompressedTexture2D” cannot be assigned to a variable of type “Color”.”, its because that the color is actually just a sprite image, but the thing is
i want it to be an image instead of an actual color because i already prepared the sprites for the ghosts, and i dont want them to go to waste (the body and eyes are in 1 image unlike in the tutorial where they are seperate image sprites), this is the code of the color variable thingy just incase you need it:
@export var color: CompressedTexture2D
modulate
changes the color of a canvas item’s texture. Maybe you mean self.texture
? depends on the node’s type, and it might be proper to change the name of the color
variable to something like texture
or image
.
i tried to change the name of the variable but didnt work, ill probably try again some time
which variable? All of my suggestions would look something like this:
func _ready():
self.texture = (get_parent() as Ghost).image # use self.texture
# ghost script
@export var image: CompressedTexture2D # rename color -> image
i tried both of them, but i replaced the “texture” in the ready function you putted with the regular “modulate” and it still works
oh yeah and the image variable also works
OH WAIT modulate doesent work nvm, replaced it with texture
with both of my changes what error do you get?
i didnt get any error except when i replaced the “texture” part with “modulate”, i then quickly changed it back to “texture”
i dont get errors when its “texture” btw,
Does everything work? Solution found? When renaming that color
variable to image
you may have to re-assign the export in the inspector.