Created
July 6, 2018 12:06
-
-
Save todorok1/a8794afd1d44e2744b322a348e229ede to your computer and use it in GitHub Desktop.
登録されていないタグはセットできるか?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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