本文整理汇总了C#中UnityEngine.Collider2D.GetComponentInChildren方法的典型用法代码示例。如果您正苦于以下问题:C# Collider2D.GetComponentInChildren方法的具体用法?C# Collider2D.GetComponentInChildren怎么用?C# Collider2D.GetComponentInChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Collider2D
的用法示例。
在下文中一共展示了Collider2D.GetComponentInChildren方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTriggerExit2D
void OnTriggerExit2D(Collider2D collider)
{
if (this.actionsInRange.Contains (collider.GetComponentInChildren<IAction> ())) {
collider.GetComponentInChildren<IAction> ().Finished ();
this.actionsInRange.Remove (collider.GetComponentInChildren<IAction> ());
}
}
示例2: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D col)
{
Debug.Log ("当たった:" + col.GetComponentInChildren<Text>().text);
if (NONE_PANEL == col.GetComponentInChildren<Text> ().text)
{
KeepPos = col.GetComponent<RectTransform>().position;
}
}
示例3: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other){
if(other.CompareTag("Player")){
other.GetComponentInChildren<Rigidbody2D>().velocity = new Vector2(0f,0f);
other.GetComponent<CharacterControllerScript>().canMove(false);
other.GetComponent<CharacterControllerScript>().fantasyArmorIdle.SetActive(true);
other.GetComponent<CharacterControllerScript>().fantasyArmorWalking.SetActive(false);
other.GetComponentInChildren<Animator>().Play("kidSmile");
doppleganger.GetComponent<Animator>().Play ("kidSmile");
credits.SetActive(true);
}
}
示例4: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.name == "Enemy"||other.gameObject.name=="Enemy(Clone)") {
other.GetComponent<PlayerStats>().ChangeHealth(-(damage));
other.GetComponentInChildren<ParticleSystem>().Emit (10);
}
}
示例5: OnTriggerEnter2D
private void OnTriggerEnter2D(Collider2D collider2d)
{
Rigidbody2D body = collider2d.GetComponent<Rigidbody2D>();
if(!body) body = collider2d.GetComponentInChildren<Rigidbody2D>();
if(!body) return;
body.drag = drag;
body.fixedAngle = true;
body.gameObject.AddComponent<LateDestroyerComponent>();
BoxCollider2D boxCollider2d = body.GetComponent<BoxCollider2D>();
if(boxCollider2d)
boxCollider2d.isTrigger = true;
body.tag = "Untagged";
foreach(Transform child in body.transform)
GameObject.Destroy(child.gameObject);
if(GameObject.FindGameObjectsWithTag("Crate").Length < 5)
GameObject.FindObjectOfType<CrateSpawner>().spawnCrate();
GameObject splash = GameObject.Instantiate(splashSystem);
splash.transform.position = new Vector2(collider2d.transform.position.x, yPos);
splash.AddComponent<TimedDestroyer>();
}
示例6: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag == "Player" && transform.parent == null) {
Item playerItem = other.GetComponentInChildren<Item> ();
if (playerItem == null) {
transform.parent = other.gameObject.transform;
transform.localPosition = new Vector3 (0, 0.8f, 0);
transform.localScale /= 1.5f;
if (item.itemType == ItemType.FAKEOBJECT) {
soundLauncher.CollectFake();
} else {
soundLauncher.CollectTop();
if (other.gameObject.name == "Lux") MusicManager.Lux(); else MusicManager.Nox();
}
} else if (playerItem.itemType == ItemType.FAKEOBJECT && item.itemType == ItemType.TOPOBJECT) {
playerItem.transform.parent = null;
playerItem.transform.localScale *= 1.5f;
transform.parent = other.gameObject.transform;
transform.localPosition = new Vector3 (0, 0.8f, 0);
transform.localScale /= 1.5f;
soundLauncher.CollectTop();
if (other.gameObject.name == "Lux") MusicManager.Lux(); else MusicManager.Nox();
}
}
/*else if (other.gameObject.tag == "Player" && transform.parent != null)
other.GetComponent<PlayerControl>().Collect(item);*/
}
示例7: OnTriggerEnterOrExit2D
public void OnTriggerEnterOrExit2D(Collider2D other)
{
if (transform.parent.GetComponent<PlayerControl>().isDashing && other.tag == "Player"){
Item playerItem = transform.parent.GetComponentInChildren<Item> ();
Item otherItem = other.GetComponentInChildren<Item> ();
if(playerItem == null || otherItem == null) {
}
else if (playerItem.itemType == ItemType.FAKEOBJECT) {
if(transform.parent.GetComponent<PlayerControl>().dashLeft)
otherItem.transform.parent.gameObject.GetComponent<Rigidbody2D>().AddForce(dashLeftForce);
else
otherItem.transform.parent.gameObject.GetComponent<Rigidbody2D>().AddForce(dashRightForce);
playerItem.transform.parent = null;
playerItem.transform.localScale *= 1.5f;
otherItem.transform.parent = transform.parent.transform;
otherItem.transform.localPosition = new Vector3 (0, 0.8f, 0);
if (otherItem.itemType == ItemType.TOPOBJECT) {
if (transform.parent.name == "Lux") MusicManager.Lux(); else MusicManager.Nox();
}
}
else if (playerItem.itemType == ItemType.TOPOBJECT) {
if(transform.parent.GetComponent<PlayerControl>().dashLeft)
otherItem.transform.parent.gameObject.GetComponent<Rigidbody2D>().AddForce(dashLeftForce);
else
otherItem.transform.parent.gameObject.GetComponent<Rigidbody2D>().AddForce(dashRightForce);
otherItem.transform.parent = null;
otherItem.transform.localScale *= 1.5f;
}
}
}
示例8: OnTriggerStay2D
void OnTriggerStay2D(Collider2D otherObj)
{
if (otherObj.tag == "Player" && !otherObj.GetComponentInChildren<GroundCheckController>().touchingGround) {
GetComponent<BoxCollider2D>().isTrigger = false;
gameObject.tag = "Ground";
}
}
示例9: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
CameraScript mainCamera = other.transform.parent.GetComponent(typeof(CameraScript)) as CameraScript;
mainCamera.active = false;
Player player = other.GetComponentInChildren(typeof(Player)) as Player;
player.StopAllCoroutines();
player.EndGame();
}
示例10: OnTriggerStay2D
public void OnTriggerStay2D(Collider2D target)
{
if (target.gameObject.tag == "Enemy")
{
target.GetComponentInChildren<PlayerHealth> ().TakeDamage (fireballBaseDamage);
Destroy (gameObject);
}
if (target.gameObject.tag == "Ground")
{
Destroy (gameObject);
}
if(target.gameObject.tag== "Flammable")
{
target.GetComponentInChildren<Torch>().activateFlammable ();
Destroy (gameObject);
}
}
示例11: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D col)
{
//print(col);
//checks to see if the collider belongs to a player
if (col.GetComponentInParent<Health>() || col.GetComponent<GrappleScript>() || col.GetComponent<ParticleSystem>() || col.GetComponentInChildren<ParticleSystem>() || col.CompareTag("Grapple")) {
if (col.GetComponent<Health>() && !respawning) SetInRespawnQueue(col.gameObject);
} else {
//print("Destroyyy");
Destroy(col.gameObject);
}
}
示例12: compare
// compares the current colour to the collider's colour
// general tool
public bool compare(Collider2D collider)
{
ModeChange mode = collider.GetComponentInChildren<ModeChange> ();
if (mode == null) {
mode = collider.GetComponentInParent<ModeChange> ();
return compare (mode);
}
else {
int colour = mode.currentColour;
return currentColour == colour; // if they are the same, return true
}
}
示例13: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D co)
{
Inventory inv = co.GetComponentInChildren<Inventory>() as Inventory;
inv.AddItem (2);
int r = Random.Range(2, 4);
for (int i = 0; i < r; i++) {
int item = Random.Range (3, 15);
if(inv){
inv.AddItem(item); }
}
Destroy (this.gameObject);
}
示例14: RespawnPlayerCo
public IEnumerator RespawnPlayerCo(Collider2D player)
{
//Instantiate(deathParticle, player.transform.position, player.transform.rotation);
player.enabled = false;
player.GetComponentInChildren<Renderer>().enabled = false;
player.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
gravityStore = player.GetComponent<Rigidbody2D>().gravityScale;
player.GetComponent<Rigidbody2D>().gravityScale = 0;
ScoreManager.AddPoints(-pointPenaltOnDeath);
yield return new WaitForSeconds(respawnDelay);
player.transform.position = checkpoint[Random.Range(0, checkpoint.Length)].transform.position;
//Instantiate(lifeParticle, currentCheckpoint.transform.position, currentCheckpoint.transform.rotation);
player.enabled = true;
player.GetComponentInChildren<Renderer>().enabled = true;
player.GetComponent<Rigidbody2D>().gravityScale = gravityStore;
}
示例15: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Zombie" && PorteObjectif == true)
{
Main.GetComponent<Timer>().GiveZPoints();
// other.Destroy(other.gameObject.Find());
}
if (other.tag == "Human" && PorteObjectif == true)
{
other.GetComponentInChildren<Human_Handling>().FuckOffIncapacitated();
}
PorteObjectif = false;
}