本文整理汇总了C#中UnityEngine.Collider2D类的典型用法代码示例。如果您正苦于以下问题:C# Collider2D类的具体用法?C# Collider2D怎么用?C# Collider2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Collider2D类属于UnityEngine命名空间,在下文中一共展示了Collider2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D c)
{
//print ("Pokeball pushes back "+c.gameObject.name);
if (c.gameObject.GetComponent<ReceiveKnockback>()!=null && c.gameObject.name != my_parent_name && !c.GetComponent<PlayerController>().locked) {
c.gameObject.GetComponent<Consciousness>().TakeDamage(3, pid);
//if what we hit is a player and isn't the player who made us...
Vector2 knockback = GetComponent<Rigidbody2D>().velocity;
knockback.Normalize ();
knockback.x *= KNOCKBACK_AMOUNT;
knockback.y *= KNOCKBACK_AMOUNT;
Knockback knockbackObject = new Knockback(KNOCKBACK_TIME,knockback);
c.gameObject.SendMessage("GetKnockedBack", knockbackObject);
//...activate the GetKnockedBack function of the thing we just hit
//causing them to fly backward! In players, this function is in PlayerMovement.
}
//ADD EXCEPTIONS FOR DIE_ON_CONTACT object destroys here \/
if (die_on_contact && c.gameObject.name != my_parent_name && c.gameObject.name!="Ring"
&& c.tag != "Coin" && c.tag != "Item" && c.tag != "Melee Hitbox" && c.tag != "Portal"
&& c.tag != "Death Floor"){
//if we hit ANYTHING but the player we came from
GameObject expl_temp = (GameObject) Instantiate(explosion, transform.position, Quaternion.identity);
Destroy(expl_temp, expl_temp.GetComponent<ParticleSystem>().startLifetime);
Destroy (gameObject);
}
}
示例2: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.tag == "Coin")
{
isActive = !isActive;
}
}
示例3: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if((other.gameObject.tag == ("LeftBullet") || other.gameObject.tag == ("RightBullet")) && gameObject.tag == ("Player1"))
{
gameController.playerHPDown();
}
if((other.gameObject.tag == ("LeftBullet") || other.gameObject.tag == ("RightBullet")) && gameObject.tag == ("Player2"))
{
gameController.playerHPDown();
}
if(other.gameObject.tag == ("Coin") && gameObject.tag == ("Player"))
{
gameController.playerScoreUp();
}
if(other.gameObject.tag == ("Hazzard") && gameObject.tag == ("Player1"))
{
gameController.playerHP = 0;
}
}
示例4: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D col)
{
if (col.gameObject.tag == "spike")
{
parent_script.HitSpikes();
}
}
示例5: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if (other.name == "Player")
{
levelManager.RespawnPlayer();
}
}
示例6: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D coll)
{
if(GameObject.Find("Player") == coll.gameObject)
{
GameObject.Find("GameManager").GetComponent<gameManager>().resetGame();
}
}
示例7: OnTriggerEnter2D
void OnTriggerEnter2D (Collider2D col){
Debug.Log (gameObject.name + " has collided with " + col.gameObject.name);
anim.SetBool (bump, true);
}
示例8: OnTriggerExit2D
public void OnTriggerExit2D(Collider2D other)
{
//Returning to patrol state after Player exits within time frame
if (other.CompareTag("Player")){
ToPatrolState();
}
}
示例9: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D col)
{
if (col.gameObject.tag == "Player")
{
col.gameObject.SendMessage("getHit");
}
}
示例10: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag ("NormalArrow") || other.CompareTag ("SplittedArrow")) {
nnflag = true;
transform.FindChild("Heart").gameObject.SetActive(true);
}
}
示例11: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other){
if(other.transform.parent){
Destroy(other.transform.parent.gameObject);
}else{
Destroy(other.gameObject);
}
}
示例12: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D collider)
{
if (collider.gameObject.tag == "Player") {
this.playerScript.OnItemCollected(this.itemName);
Destroy(this.gameObject);
}
}
示例13: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D enemy)
{
if (enemy.gameObject.GetComponent<Player> () == null)
return;
Debug.Log ("trigger entered");
eventHandler.HandleClash ();
}
示例14: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D c)
{
//レイヤー名取得
string layerName = LayerMask.LayerToName(c.gameObject.layer);
//レイヤー名がBullet(Player)以外のとき
if( layerName != "Bullet(Player)") return;
//PlayerBulletのTransformを取得
Transform playerBulletTransform = c.transform.parent;
//Bulletコンポーネントを取得
Bullet bullet = playerBulletTransform.GetComponent<Bullet> ();
//ヒットポイントを減らす
hp = hp - bullet.power;
//弾の削除
Destroy(c.gameObject);
//ヒットポイントが0以下であれば
if (hp <= 0) {
//スコアコンポーネントを取得してポイントを追加
FindObjectOfType<Score>().AddPoint(point);
//爆発
spaceship.Explosion ();
//エネミーの削除
Destroy (gameObject);
} else {
spaceship.GetAnimator ().SetTrigger ("Damage");
}
}
示例15: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D col)
{
if (col.tag == "Fog") {
col.gameObject.GetComponent<FogMovement>().multiplier *= -1;
StartCoroutine(DeadTime(col.gameObject));
}
}