• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# UnityEngine.BoxCollider2D类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UnityEngine.BoxCollider2D的典型用法代码示例。如果您正苦于以下问题:C# BoxCollider2D类的具体用法?C# BoxCollider2D怎么用?C# BoxCollider2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BoxCollider2D类属于UnityEngine命名空间,在下文中一共展示了BoxCollider2D类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: addFire

    private void addFire(Transform parent)
    {
        fireObject = new GameObject("FireIcon_" + fireHolder.transform.childCount);
        fireSprite = Resources.Load<Sprite>("Sprites/Fire/SmallFire_Object");
        fireRenderer = fireObject.AddComponent<SpriteRenderer>();
        fireRenderer.sprite = fireSprite;
        fireCollider = fireObject.AddComponent<BoxCollider2D>();
        fireRenderer.sortingOrder = 1;
        fireObject.transform.parent = fireHolder.transform;

        float screenDPI = Screen.dpi / 160;

        float xSize = fireSprite.bounds.size.x;
        float ySize = fireSprite.bounds.size.y;

        float width;
        float height;

        if (screenDPI > 0)
        {
            width = 204 * screenDPI;
            height = 330 * screenDPI;
        }
        else
        {
            width = 204 * parent.transform.localScale.x / 2;
            height = 280 * parent.transform.localScale.y / 2;
        }

        float worldwidth = (camera.orthographicSize * 2 / Screen.height * width) / xSize;
        float worldHeight = (camera.orthographicSize * 2 / Screen.height * height) / ySize;

        fireObject.transform.localScale = new Vector3(worldwidth, worldHeight, 1);
    }
开发者ID:Cryslo,项目名称:EMSRisicoStage,代码行数:34,代码来源:Drag_Fire_Script.cs


示例17: Start

		// Use this for initialization
		void Start () {
			spriteRenderer = GetComponent<SpriteRenderer>();
			collider = GetComponent<BoxCollider2D> ();
			audioSource = GetComponent<AudioSource> ();

			this.FollowPath();	
		}
开发者ID:fromtons,项目名称:meme-pas-peur_app,代码行数:8,代码来源:Luciole.cs


示例18: Start

    // Use this for initialization
    void Start()
    {
        rb2d    = GetComponent<Rigidbody2D>();
        boxColl = GetComponent<BoxCollider2D>();

        usingController = false;
    }
开发者ID:felipeUmbra,项目名称:Test1,代码行数:8,代码来源:PlayerActions.cs


示例19: Start

	// Use this for initialization
	void Start () {
        rigid = GetComponent<Rigidbody2D>();
        box = GetComponent<BoxCollider2D>();
        Manager.gManager.player = this;
        Manager.gManager.asignedPlayer = this.gameObject;
        anim = GetComponent<Animator>();
	}
开发者ID:ValdesJuan,项目名称:JimboGrimbo,代码行数:8,代码来源:Grimbo.cs


示例20: Start

	// Use this for initialization
	void Start ()
    {
        level = GameObject.FindGameObjectWithTag("levelGen").GetComponent<LevelGeneration>();
        checkMovement = GetComponent<BoxCollider2D>();
        rb = GetComponent<Rigidbody2D>();
        checkMovement.offset = new Vector2(0, -1);
	}
开发者ID:TeamThreeProject,项目名称:Project,代码行数:8,代码来源:PlayerMovement.cs



注:本文中的UnityEngine.BoxCollider2D类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UnityEngine.Camera类代码示例发布时间:2022-05-26
下一篇:
C# UnityEngine.BoxCollider类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap