+1 vote

I have a scene that's supposed to mimic a planet. It's current node setup is simply RigidBody > CollisionShape > MeshInstance. The arrows represent parent-child relationship. I have a script on the RigidBody where a color variable is exported so it can be changed via the editor. This is the _ready function of the script:

func _ready():
var material = SpatialMaterial.new()
material.albedo_color = color
get_node("CollisionShape/MeshInstance").get_mesh().set_material(material)
currentVelocity = initialVelocity

This is not working, for some reason. I've tried many combinations of selecting the mesh of the MeshInstance and changing the color of the material or doing what I'm doing now and setting the material of the mesh to a new one with the desired color altogether. I feel like changing the color should be this easy, but perhaps I'm missing something. Any help is greatly appreciated!

in Engine by (31 points)

have the same problem. Any update on this? have you figured it out?

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.