Question by
chrisTheBomb23 · Jul 06, 2019 at 02:30 AM ·
physicsphysics2dcollider2dpolygon collider 2d
How can i get a transform to move to another transform if it is touching it?
i am trying to make a battle system where you can only move to the next button while you on a different one, and while trying to do this, i think it got to complex from me failing, and i have no idea what is not working. so can you guys help me? {
private float MenuX;
public PolygonCollider2D fightButtonCo;
public PolygonCollider2D actButtonCo;
public PolygonCollider2D itemButtonCo;
public PolygonCollider2D mercyButtonCo;
public PolygonCollider2D SoulCo;
public GameObject fightButton;
public GameObject actButton;
public GameObject itemButton;
public GameObject mercyButton;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
MenuX = Input.GetAxis("Horizontal");
if (MenuX >= .5)
{
if (SoulCo.IsTouching(fightButtonCo))
{
transform.position = actButton.transform.position;
}
}
}
}
Comment