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()
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 Engine by (93 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 (16,634 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 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.