- Home /
repeating help with the tag plzz is insulting everyone trying to help
How to use tag for all players in the Instantiate.
//need help with this Instantiate (playerdestroyEffect, Player.position, Player.rotation); //and this public Transform Player i want transform to player tag (for all players)
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class playerInventory : MonoBehaviour {
public Vector3 EndPoint;
public Transform Player;
public GameObject playercastom;
public GameObject playerparkur;
public GameObject playerparkurblue;
public GameObject botcastom;
public GameObject playerdestroyEffect;
public void Update()
{
}
public void OnClick()
{
GameObject[] playerObjects = GameObject.FindGameObjectsWithTag("Player");
foreach (GameObject playerObject in playerObjects)
{
Instantiate (playerdestroyEffect, Player.position, Player.rotation);
Destroy(GameObject.FindWithTag("Player"));
Instantiate (playercastom, EndPoint, Quaternion.identity);
}
}
public void OnClickP()
{
GameObject[] playerObjects = GameObject.FindGameObjectsWithTag("Player");
foreach (GameObject playerObject in playerObjects)
{
Instantiate (playerdestroyEffect, Player.position, Player.rotation);
Destroy (GameObject.FindWithTag ("Player"));
Instantiate (playerparkur, EndPoint, Quaternion.identity);
}
}
public void OnClickPB()
{
GameObject[] playerObjects = GameObject.FindGameObjectsWithTag("Player");
foreach (GameObject playerObject in playerObjects)
{
Instantiate (playerdestroyEffect, Player.position, Player.rotation);
Destroy(GameObject.FindWithTag("Player"));
Instantiate (playerparkurblue, EndPoint, Quaternion.identity);
}
}
public void OnClickSS()
{
GameObject[] playerObjects = GameObject.FindGameObjectsWithTag("Player");
foreach (GameObject playerObject in playerObjects)
{
Instantiate (playerdestroyEffect, Player.position, Player.rotation);
Destroy (GameObject.FindWithTag ("Player"));
Instantiate (botcastom, EndPoint, Quaternion.identity);
}
}
}
https://answers.unity.com/questions/344544/instantiate-an-object-on-another-object.html This older post should explain what your trying to do as it has the same topic and similar script, although I agree with hexagonius. What help?
do you want to run your Instantiate code for all gameobjects with the tag "Player" ?
Follow this Question
Related Questions
how to spawn object on the player C# 2 Answers
player spawning 0 Answers
How to create Prefab with property 2 Answers
Multiple Cars not working 1 Answer
Rotating a player object without rotating the axis 0 Answers