![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | dmarques42 |
Sorry for the beginner question, but I am spinning my wheels.
I am an experienced programmer, in python and in 2D game engines, new to 3D and to Godot. I have read through the docs and API especially quite a bit, followed a few tutorials, but cannot find an example that helps or find anything with search. Apologies if I have missed it.
Context: Simple room with 4 walls, and a signal (that I created) should change the image (via texture, I think) on a wall.
What works: The signal works, the image load works, texture creation, no error spit out.
Problem: The wall just turns white, no image on it that I can detect. I am not understanding how to use an image as a texture. Maybe I have to create the wall as a different kind of surface? (I also tried putting the image on a plane, same result.)
Relevant code: (excuse the naive code, array, this is just to get it working)
[full source code for a newer version of this simple test is available at https://www.ideategames.org/Rooms1.zip]
var mats = []
func _set_image(wnum,inum):
print("setting image wall: "+str(wnum)+":"+str(inum))
var tex = ImageTexture.new()
tex.create_from_image(mats[inum],1)
# this next line makes no difference that I can see,
# no matter the values, 0.25 - 200
tex.set_size_override(Vector2(200,200))
var wnode = "../Wall"+str(wnum)+"/WallMesh"
# both methods below have the same result
# changing the surface number results in no error but no change
get_node(wnode).set_surface_material(0,tex)
# get_node(wnode).texture = tex
# Called when the node enters the scene tree for the first time.
func _ready():
mats.append(Image.new())
mats[-1].load("images/Birth_Of_Venus.jpg")
# this doesn't seem to make any difference no matter the values
mats[-1].resize(0.25,0.25)
get_node("../Player").connect("wall_image", self, "_set_image")