0 votes

I have an enemy that is a rigid body, and has a sprite as a child.

I can modify its speed and rotation after instantiating it, but I cannot modify the sprite

var mob = Mob.instance()
add_child(mob)
mob.rotation = direction
mob.linear_velocity = Vector2(rand_range(mob.min_speed, mob.max_speed), 0)     
mob.linear_velocity = mob.linear_velocity.rotated(direction)

try this way but it returns an error

mob/Sprite.texture = load("res://Img/yellow.png")
in Projects by (90 points)

What error do you get, specifically.

Parser Error: Can't assign to an expression

1 Answer

0 votes
Best answer

That needs to be:

mob.get_node("Sprite").texture = ...
by (10,690 points)
selected by

Thank you very much, it works perfect

Sorry for the inconvenience but I could open a way to call it from a Singleton (AutoLoad)

Mmmm... I really don't understand what you're asking here... Call what from a singleton?

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 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 webmaster@godotengine.org with your username.

Categories