Skip to content

Instantly share code, notes, and snippets.

@todorok1
Created July 6, 2018 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todorok1/a8794afd1d44e2744b322a348e229ede to your computer and use it in GitHub Desktop.
Save todorok1/a8794afd1d44e2744b322a348e229ede to your computer and use it in GitHub Desktop.
登録されていないタグはセットできるか?
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