Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class SetTagTest : MonoBehaviour {
// Rigidbodyがアタッチされたフラグ
bool isRigidbodyAttached;
GameObject getByTagObj;
Rigidbody rb;
string tagName = "MyNewTag";
void Start(){
gameObject.tag = tagName;
getByTagObj = GameObject.FindGameObjectWithTag(tagName);
rb = getByTagObj.AddComponent<Rigidbody>();
isRigidbodyAttached = true;
void FixedUpdate(){
if (isRigidbodyAttached){
rb.AddForce(new Vector3(15f, 15f, 15f));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment