當前位置: 首頁>>代碼示例>>C#>>正文


C# UnityEngine.BoxCollider2D類代碼示例

本文整理匯總了C#中UnityEngine.BoxCollider2D的典型用法代碼示例。如果您正苦於以下問題:C# BoxCollider2D類的具體用法?C# BoxCollider2D怎麽用?C# BoxCollider2D使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BoxCollider2D類屬於UnityEngine命名空間,在下文中一共展示了BoxCollider2D類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: MoveVertical

    public static float MoveVertical(BoxCollider2D box, float dy, out bool col)
    {
        col = false;
        if (dy == 0.0f) {
            return dy;
        }

        var min = box.bounds.min;
        var max = box.bounds.max;

        float ret = dy;
        if (dy > 0) {
            for (int i = (int)min.x + 1; i <= (int)max.x - 1; i += 1) {
                var hit = Physics2D.Raycast (new Vector2 (i, max.y), Vector2.up, Mathf.Abs(dy), tileLayer);
                if (hit.collider != null) {
                    col = true;
                    ret = Mathf.Min (ret, hit.distance);
                }
            }
        } else if (dy < 0) {
            for (int i = (int)min.x + 1; i <= (int)max.x - 1; i += 1) {
                var hit = Physics2D.Raycast (new Vector2 (i, min.y), Vector2.down, Mathf.Abs(dy), tileLayer | ladderEndLayer);
                if (hit.collider != null) {
                    col = true;
                    ret = Mathf.Max (ret, -hit.distance);
                }
            }
        }

        return ret;
    }
開發者ID:djoyahoy,項目名稱:uniman2,代碼行數:31,代碼來源:CC2D.cs

示例2: Awake

 void Awake()
 {
     sprite = GetComponent<SpriteRenderer>();
     body = GetComponent<Rigidbody2D>();
     col = GetComponent<BoxCollider2D>();
     parentBalista = transform.parent.gameObject;
 }
開發者ID:KneeDeepAudio,項目名稱:CauseAndEffect,代碼行數:7,代碼來源:BallistaArrow.cs

示例3: Start

	// Use this for initialization
    void Start()
    {
        rigid = GetComponent<Rigidbody2D>();
        box = GetComponent<BoxCollider2D>();
        esperando = espera;
        anim = GetComponent<Animator>();
	}
開發者ID:ValdesJuan,項目名稱:JimboGrimbo,代碼行數:8,代碼來源:Enemigo1.cs

示例4: Start

 void Start()
 {
     _spriteRenderer = GetComponent<SpriteRenderer>();
     _boxCollider = GetComponent<BoxCollider2D>();
     _isLaserVisible = isLaserVisibleOnStart;
     ChangeLaserApperance ();
 }
開發者ID:zgredziucha,項目名稱:areria,代碼行數:7,代碼來源:LaserBlink.cs

示例5: Awake

	/*---------------------------------------------------- AWAKE ----------------------------------------------------*/

    void Awake()
    {
        powerManager = GameObject.Find("GameManager").GetComponent<PowerManager>();

        anim = transform.FindChild("Animation").GetComponent<Animator>();

        effectorCollider1 = transform.FindChild("AreaEffectors").GetChild(0).GetComponent<BoxCollider2D>();
        effectorCollider2 = transform.FindChild("AreaEffectors").GetChild(1).GetComponent<BoxCollider2D>();
        effectorCollider3 = transform.FindChild("AreaEffectors").GetChild(2).GetComponent<BoxCollider2D>();

        consoleViewImage = transform.FindChild("ConsoleView").GetComponent<SpriteRenderer>();

        powerCost = GetComponent<Power>().powerCost;

        GameObject fanDistance = transform.FindChild("FanDistance").gameObject;

        float difference = Vector2.Distance(transform.position, fanDistance.transform.position);

        effectorCollider1.size = new Vector2(difference-1, effectorCollider1.size.y);
        effectorCollider1.offset = new Vector2(difference / 2, 0);

        effectorCollider2.size = new Vector2(difference - 1, effectorCollider2.size.y);
        effectorCollider2.offset = new Vector2(difference / 2, 1.7f);

        effectorCollider3.size = new Vector2(difference - 1, effectorCollider3.size.y);
        effectorCollider3.offset = new Vector2(difference / 2, -1.7f);
    }
開發者ID:NoManAlone,項目名稱:No-Man-Alone-Vertical-Slice---Scripts,代碼行數:29,代碼來源:FanBehaviours.cs

示例6: Start

	// Use this for initialization
	void Start () {
        ac = this.gameObject.GetComponent<AttributeComponent>();
        bc = this.gameObject.GetComponent<BoxCollider2D>();
		pbc = GameObject.FindWithTag ("Projectile").GetComponent <BoxCollider2D>();
        anim = (Animator)GetComponent(typeof(Animator));
        meleeSys = (MeleeSystem)GetComponent(typeof(MeleeSystem));
	}
開發者ID:DerjenigeWelche,項目名稱:Medienprojekt2.0,代碼行數:8,代碼來源:HealthSystem.cs

示例7: Awake

 void Awake()
 {
     _Animator = GetComponent<Animator>();
     _BoxCollider = GetComponent<BoxCollider2D>();
     _Rigidbody = GetComponent<Rigidbody2D>();
     _AudioSource = GetComponent<AudioSource>();
 }
開發者ID:sgmtjp,項目名稱:Git-SODATERUTOWER,代碼行數:7,代碼來源:Player.cs

示例8: Start

		// Use this for initialization
		void Start () {
			animator = this.GetComponent<Animator> ();
			boxCollider = this.GetComponent<BoxCollider2D> ();
			audioSource = this.GetComponent<AudioSource>();
			
			audioSource.clip = soundOnTouch;
		}
開發者ID:fromtons,項目名稱:meme-pas-peur_app,代碼行數:8,代碼來源:Mushroom.cs

示例9: Start

     //private Animator animator;


     public void Start()
     {
          // Components
          moveController = GetComponent<EnemyMoveController>();
          animationController = GetComponent<AnimationController>();
          sprRend = GetComponent<SpriteRenderer>();
          collider = GetComponent<BoxCollider2D>();
          health = GetComponent<Health>();
          player = FindObjectOfType<Player>();

          //laser = GetComponent<Projectile> ();
          //laserObject = GetComponent <Projectile> ();

          //rigidbody2D.mass = 10;

          distance = new Vector2(0, 0);
          speed = new Vector2(0, 0);
          isAgro = false;

          rnd = new System.Random(Guid.NewGuid().GetHashCode());
          t = 3 + rnd.Next(0, 3000) / 1000f;

          teleporting = false;
          teleportCD = 11;
          temp = 0;
          canTeleport = true;

          facing = new Vector2(0, 0);

     }
開發者ID:pmer,項目名稱:zombie-ninja-attack-craft,代碼行數:33,代碼來源:Cyclops.cs

示例10: Start

 void Start()
 {
     score=GameObject.Find("Canvas").GetComponent<GameManager>();
     box=GetComponent<BoxCollider2D>();
     scoreTrans=GameObject.Find("score100(Clone)").GetComponent<scoreTransformer>();
     player=GameObject.Find ("Player").transform;
 }
開發者ID:OzanOcak,項目名稱:Game_Csharp,代碼行數:7,代碼來源:Stages.cs

示例11: Start

 /* deben hacerse todos los getcomponent y los valores que se quieran por defecto*/
 void Start()
 {
     boxcollider2D = GetComponent<BoxCollider2D>();
     colorpersonaje = (GameObject.FindWithTag ("Player")).GetComponent<Color_Personaje>();
     spriterenderer = GetComponent<SpriteRenderer>();
     //porAbajo = false;
 }
開發者ID:guillermoblanca,項目名稱:BH,代碼行數:8,代碼來源:Bloque_Color.cs

示例12: Start

	// Use this for initialization
	void Start () {
        spriteRenderer = GetComponent<SpriteRenderer>();
        boxCollider = GetComponent<BoxCollider2D>();
        timeSpentActive -= timeOffset;
        isActive = false;
        unactiveDuration = activeDuration + 2f;
	}
開發者ID:pmer,項目名稱:zombie-ninja-attack-craft,代碼行數:8,代碼來源:SpikeTrap.cs

示例13: Awake

    protected virtual void Awake() {
//        inputState = GetComponent<InputState>();
        abductBody2d = GetComponent<Rigidbody2D>();
        abductCollisionState = GetComponent<CollisionState>();
        boxCollider = GetComponent<BoxCollider2D>();

    }
開發者ID:henarky,項目名稱:HFPB,代碼行數:7,代碼來源:AbducteeBehavior.cs

示例14: Awake

 void Awake()
 {
     scriptpersonaje =GameObject.FindWithTag ("Player").GetComponent <CambiaColor_CH>();
     boxcollider2D = GetComponent<BoxCollider2D>();
     spriterenderer = GetComponent<SpriteRenderer>();
     ColoresBloque();
 }
開發者ID:guillermoblanca,項目名稱:BlackHole,代碼行數:7,代碼來源:BloqueColor.cs

示例15: Start

 // Use this for initialization
 void Start()
 {
     selfCollider = transform.GetComponent<BoxCollider2D>();
     colliderx = selfCollider.size.x / 2f;
     collidery = selfCollider.size.y / 2f;
     eventMng = GameObject.FindGameObjectWithTag("Manager").GetComponent<ClickEventManager>();
 }
開發者ID:Chapapaa,項目名稱:FasterThanShark,代碼行數:8,代碼來源:GetClickedRoom.cs


注:本文中的UnityEngine.BoxCollider2D類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。