How do I get an object in Unity to move down the Y-axis?

Viewed 30
public GameObject enemyfireball;


void Update()
{
    enemyfireball.transform.position += -transform.up * Time.deltaTime * 5f;
}

I am not sure how to make this work in a different way, the object just won't move. For reference this is for a 2D game.

1 Answers

transform is local, so transform.up is up to what object this script is on. Try using Vector3.down (or Vector3.up).

Something like

public GameObject enemyfireball;


void Update()
{
    enemyfireball.transform.position += Vector2.down * Time.deltaTime * 5f;
}
Related