You could easily just add in an else statement, to check if the player is in the ship or not. Something like:
void OnTriggerStay2D(Collider2D col)
{
if (Input.GetButtonDown ("Fire1"))
{
if (!IsPlayerOnShip)
{
if (col.name == "Player")
{
IsPlayerOnShip = true;
Player.SetActive (false);
}
}
else
{
if (IsPlayerOnShip)
{
if (col.name == "Grass1")
{
IsPlayerOnShip = false;
Player.transform.position = col.transform.position;
Player.SetActive (true);
}
}
}
}
}
Pretty much, it simply checks if the player is in the ship, if not, put him in. If so, take hime out. Voilà.
Hope this works for you! (I've never used C#, but it should work I hope)
↧