Skip to content

Instantly share code, notes, and snippets.

Embed
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
You can’t perform that action at this time.