Question by
PitrasCz · Jan 26, 2017 at 03:10 PM ·
c#2d gamepositioning
Buy system - transform.position bought object
Hi, I have this script to buy item.. But when i bought an item, so spawn at 0 , 0 , 0 pos.. I need to spwan at the last position of the player on which it is. How can i do it? Thank you.
using System; using UnityEngine; using UnityEngine.UI; using System.Collections;
public class ShopButton : MonoBehaviour {
public Button shopOpen;
public Button Exit;
public Canvas Shop;
public Button Ship01btn;
public GameObject player;
private Vector3 offset;
public GameObject ship1; //Default ship
public GameObject ship2; //Ship in SHOP - to buy
void Start () {
shopOpen = shopOpen.GetComponent<Button>();
Ship01btn = Ship01btn.GetComponent<Button>();
Exit = Exit.GetComponent<Button>();
Shop = Shop.GetComponent<Canvas>();
Shop.enabled = false;
ship1.SetActive(true);
ship2.SetActive(false);
}
public void Buy()
{
ship2.transform.position = ship1.transform.position + offset;
ship1.SetActive(false);
ship2.SetActive(true);
}
public void Open()
{
Shop.enabled = true;
}
public void ExitPress()
{
Shop.enabled = false;
}
void Update () {
} }
Comment