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


C# UnityEngine.CircleCollider2D類代碼示例

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


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

示例1: Start

 // Use this for initialization
 void Start()
 {
     currRadius = 0f;
     circleCollider = GetComponent<CircleCollider2D>();
     circleCollider.radius = currRadius;
     Instantiate(shockwaveFXPrefab, transform.position, Quaternion.identity);
 }
開發者ID:MangoSister,項目名稱:Doot-Doot-Cat,代碼行數:8,代碼來源:Shockwave.cs

示例2: Awake

 void Awake()
 {
     transform = GetComponent<Transform>();
     Gravity = GetComponent<CircleCollider2D>();
     _player = GameObject.FindGameObjectWithTag("Player").GetComponent<LookAtMouseMove>();
    
 }
開發者ID:GCBox,項目名稱:WouldUConquer,代碼行數:7,代碼來源:Planet_Gravity.cs

示例3: Start

 public void Start()
 {
     findedEnemys = new List<BaseEnemy>();
     _player = transform.parent.GetComponent<Player>();
     _collider = transform.GetComponent<CircleCollider2D>();
     _baseRadius = _collider.radius;
 }
開發者ID:teamzeroth,項目名稱:retroboy,代碼行數:7,代碼來源:EnemiesRadar.cs

示例4: IgnoreCollisions

 public void IgnoreCollisions(CircleCollider2D coll)
 {
     foreach (Transform child in transform)
     {
         Physics2D.IgnoreCollision(child.GetComponent<BoxCollider2D>(), coll);
     }
 }
開發者ID:vernw,項目名稱:Torque2D,代碼行數:7,代碼來源:WallController.cs

示例5: Awake

    void Awake()
    {
        rigidbody = GetComponent<Rigidbody2D>();
        body = GetComponent<PolygonCollider2D>();
        feet = GetComponent<CircleCollider2D>();
        health = GetComponent<Health>();
        standing = body.points;
        crouched = new Vector2[standing.Length];
        grounded = false;
        onWall = false;
        upSlope = false;
        downSlope = false;

        int min = 0;
        for (int i = 0; i < standing.Length; i++)
        {
            if (standing[i].y < standing[min].y)
                min = i;
        }
        for (int i = 0; i < standing.Length; i++)
        {
            float newY = (standing[i].y - standing[min].y) * 0.5f + standing[min].y;
            crouched[i] = new Vector2(standing[i].x, newY);
        }
    }
開發者ID:pueblak,項目名稱:ProjectDarkZone,代碼行數:25,代碼來源:PlayerController.cs

示例6: IsOverLappingWithAnother

	private bool IsOverLappingWithAnother(CircleCollider2D col){
		Collider2D[] colliders = FindObjectsOfType<Collider2D>();

		float checkGap = 0.1f;

		int ySign = 1;
		foreach(Collider2D testCol in colliders){
			if (testCol.gameObject != col.gameObject){
				for (int i = 1; i <= 2; i++){

					for (float x = col.transform.position.x - col.radius; x <= col.transform.position.x + col.radius; x += checkGap){
						Vector2 checkPoint = new Vector2(x, ySign * Mathf.Sqrt(Mathf.Pow(col.radius,2) - Mathf.Pow((x - col.transform.position.x ),2)) + col.transform.position.y);
						Debug.Log("PIE");
						if (testCol.OverlapPoint(checkPoint)){
							return true;
						}
							
					}
					ySign = -1;
				}
			}

		}
		return false;
	}
開發者ID:james-sullivan,項目名稱:StickeyBallGame,代碼行數:25,代碼來源:PrintINtersection.cs

示例7: Start

	// Use this for initialization
	void Start () {
        rbody = GetComponent<Rigidbody2D>();
        collider = GetComponent<CircleCollider2D>();
        selectorRenderer = selector.GetComponent<SpriteRenderer>();
        selectorRenderer.enabled = false;
        charController = GameObject.FindWithTag("Player").GetComponent<CharacterController>();
    }
開發者ID:mvancompernolle,項目名稱:Cyber-Monday,代碼行數:8,代碼來源:InteractionController.cs

示例8: Awake

 // Use this for initialization
 protected override void Awake()
 {
     base.Awake();
     vfx = GetComponent<ParticleSystem>();
     coll = GetComponent<CircleCollider2D>();
     effector = GetComponent<PointEffector2D>();
 }
開發者ID:AlbearKamoo,項目名稱:Witches-vs-Aliens-2015-2016,代碼行數:8,代碼來源:PushAbilityCircle.cs

示例9: Awake

 void Awake()
 {
     spring = GetComponent<SpringJoint2D>();
     rigid2d = GetComponent<Rigidbody2D>();
     collider2d = GetComponent<CircleCollider2D>();
     catapult = spring.connectedBody.transform;
 }
開發者ID:dogwynn,項目名稱:AngryMeteor,代碼行數:7,代碼來源:ProjectileDragging.cs

示例10: Start

    // Use this for initialization
    public override void Start()
    {
        base.Start();

        exploded = false;
        explosionRadius = gameObject.GetComponent<CircleCollider2D>();
    }
開發者ID:BrockyBoi,項目名稱:Block-buster-mobile-game,代碼行數:8,代碼來源:FrezeBlockScript.cs

示例11: charge

 void charge()
 {
     numShots = 0;
     if (chargedShot==null) {
         charge_anim.SetBool("charge", true);
         chargedShot = Instantiate (gun.bullet, gun.firingLocation.position, Quaternion.identity) as Rigidbody2D;
         chargedShot.gameObject.SetActive(true);
         chargedCollider = chargedShot.GetComponent<CircleCollider2D>();
         chargedCollider.enabled = false;// disable the collider first
         script = chargedShot.GetComponent<BulletScript>(); // assign the script
         if (master.shipMode){
             chargedShot.rotation = 90; // 270 degrees means facing north
         }
         else {
             master.setCharge(1f); // set 'charging' layer to activate
         }
         chargedShot.GetComponent<SpriteRenderer>().enabled = false;
     } else { //if (chargeLevel<=totalCharge)
         Vector3 size = chargedShot.transform.localScale;
         chargedShot.transform.localScale = new Vector3(size.x*1.5f, size.y*1.5f, 1f);
         script.damage = script.damage*2;
     }
     // make the charged shot stronger
     chargeLevel++;
 }
開發者ID:Vylantze,項目名稱:Chaos-Children,代碼行數:25,代碼來源:Charge.cs

示例12: Start

 // Use this for initialization
 void Start()
 {
     col = GetComponent<CircleCollider2D>();
     men = GameObject.Find("Menu");
     win = new Window(new Vector4((Screen.width - 100)/2,(Screen.height - 100)/2, 100, 100));
     script = men.GetComponent<Menu>();
 }
開發者ID:JoeyKanaly,項目名稱:todoUnity,代碼行數:8,代碼來源:AddTask.cs

示例13: Start

 void Start()
 {
     //moveVector = new Vector2(;
     col = GetComponent<CircleCollider2D> ();
     anim = GetComponent<Animator> ();
     //test arguments
 }
開發者ID:campbellcompton,項目名稱:Disasteroids,代碼行數:7,代碼來源:Bullet.cs

示例14: Start

		// Use this for initialization
		void Start () {
			particles = GetComponent<ParticleSystem>();
			circleColider = GetComponent <CircleCollider2D>();
			animator = GetComponent<Animator>();

			timeToRespawn = timeToRespawn + Random.Range ( timeToRespawn * 0.96f , timeToRespawn * 1.04f);
		}
開發者ID:Kundara,項目名稱:project1,代碼行數:8,代碼來源:BunchOfLeaves.cs

示例15: Start

    public void Start()
    {
        // 30 rays at minimum
        var alpha = Mathf.Acos(Resources.MinSizeOfEnemy / 2 * Radius) * Mathf.Rad2Deg;
        _minAngle = 180 - 2 * alpha;
        _minAngle -= SkinRadius;
        _detectedEnemies = new List<BoxCollider2D>();

        _sonarCollider = GetComponent<CircleCollider2D>();
        if (_sonarCollider == null)
            Debug.LogError("Sonar Collider component has not been assigned");
        if (Type == Resources.FriendlyReconType.Sonar)
        {
            _sonarDetection = true;
            _sonarCollider.radius = Radius;
            _sonarCollider.isTrigger = true;
        }

        _circularDetectionAngle = 0f;
        _angleBetweenRays = 360f / NumberOfRays;

        _backgroundManager = GetComponent<FriendlyBackgroundManager>();
        if (_backgroundManager == null)
            Debug.LogError("Background Mananger is null");
    }
開發者ID:sathiyavrs,項目名稱:Hit-The-Green-Cube,代碼行數:25,代碼來源:FriendlyReconManager.cs


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