Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | 1-Tap |
Im currently working on a project, which is a Strategygame in Space. For that I wanted to load the textures of each planet. This is the Code of each Planet (MeshInstance), render() is being called when the Solarsystem is opened.
extends MeshInstance
func render(planettype, textureytype):
var texture_path
var texture = String(textureytype)
if planettype == 0:
texture_path = "Sun" + texture + ".jpg"
if planettype == 1:
texture_path = "Waterplanet" + texture + ".jpg"
if planettype == 2:
texture_path = "Exoplanet" + texture + ".jpg"
if planettype == 3:
texture_path = "Rockplanet" + texture + ".jpg"
if planettype == 4:
texture_path = "Gasplanet" + texture + ".jpg"
if planettype == 5:
texture_path = "Poisoned" + texture + ".jpg"
if planettype == 6:
texture_path = "Waterplanet" + texture + ".jpg"
var actual_path = "res://Designs/Planets/" + texture_path
apply_texture(actual_path)
func apply_texture(actual_path):
var texture = ImageTexture.new()
var image = Image.new()
image.load(actual_path)
texture.create_from_image(image)
self.material_override.albedo_texture = texture <-- here is probably the mistake
When I want to load it, it either doesn’t load the image at all, or says "Invalid set index ‘albedo_texture’ "
Im using Godot v3.1.1