当前位置: 首页>>代码示例>>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;未经允许,请勿转载。