Can i change properties of an intantiated object?
I'm very new to godot and i'm trying to make a very simple game.
I have an enemy spawn. It needs to spawn enemies. Enemies need to walk from right to left, friendly units walk from right to left and then they fight and whoever destroys the enemies base first wins.
My enemy_base.gd looks like this:
``` extends Sprite2D
var enemy = preload("res://scenes/enemy.tscn")
Called when the node enters the scene tree for the first time.
func _ready() -> void: var spawn = get_node("EnemySpawn");
var instance = enemy.instantiate();
spawn.add_child(instance)
instance.global_position = self.global_position
#instance.direction = Vector2(0, 1)
var sprite = instance.get_node_or_null("AnimatedSprite2D")
sprite.flip_h = true
sprite.scale = Vector2(0.25, 0.25)
sprite.position.y = 8
```
And my enemy.gd looks like this:
``` extends CharacterBody2D
Movement properties
const SPEED = 150 const JUMP_VELOCITY = -400.0
var direction = Vector2(1, 0) # Default to moving right
Called every frame
func _physics_process(delta: float) -> void: velocity.x = direction.x * SPEED move_and_slide()
```
I have a direction variable. If i make it Vector2(-1, 0) it moves from right to left.
Can i modify it? Can i make it static for example?