i am having trouble updating my vector2 data from my function. The objective of this vector2 is to save the dead enemy position but when i use it globally it goes to 0,0 when inside the function it has the right values.
Heres is the code
private Vector2 enemyPosition;
void Update()
{
Debug.Log("enemyPosition update: " + enemyPosition);
gameObject.transform.position = Vector2.MoveTowards(transform.position, enemyPosition, blobSpeed * Time.deltaTime);
}
public void createBlobMelee(GameObject enemy)
{
enemyPosition = new Vector2(enemy.transform.position.x, enemy.transform.position.y);
Debug.Log("enemyPosition: " + enemyPosition);
randomBlobx = Random.Range(-1, 1);
randomBloby = Random.Range(-1, 1);
Vector2 randomBlobCreate = new Vector2(enemy.transform.position.x + randomBlobx, enemy.transform.position.y + randomBloby);
Instantiate(gameObject, randomBlobCreate, Quaternion.identity);
}
And this is the results from the debug console.
Thank you for you time, André Sousa
