当前位置: 首页>>代码示例>>C#>>正文


C# Collider2D.GetInstanceID方法代码示例

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


在下文中一共展示了Collider2D.GetInstanceID方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnTriggerExit2D

 void OnTriggerExit2D(Collider2D _other)
 {
     if (_other.GetInstanceID() == m_DeadzoneColliderID)
     {
     //             Debug.Log("Projectile leaved deadzone. Activate.");
         GetComponent<Projectile>().Activate();
         Destroy(this);
     }
 }
开发者ID:JamesKim2998,项目名称:snugdc-project-ricochet,代码行数:9,代码来源:ProjectileDecoratorDeadzone.cs

示例2: OnTriggerEnter2D

	void OnTriggerEnter2D(Collider2D other) {
		IndicatorArrow arrowClone = Instantiate (arrow, new Vector3(parent.transform.position.x,parent.transform.position.y,arrow.transform.position.z),
		                                         arrow.transform.rotation) as IndicatorArrow;
		arrowClone.transform.parent = parent.transform;
		arrowClone.target = other.gameObject;
		arrowClone.fromPos = parent;
//		arrowClone.rotate();
		arrowClone.maxRange = range;

		arrows[other.GetInstanceID ()] = arrowClone;
	}
开发者ID:LatexBotox,项目名称:SPACE,代码行数:11,代码来源:Radar.cs

示例3: OnTriggerEnter2D

 void OnTriggerEnter2D(Collider2D c)
 {
     var layerName = LayerMask.LayerToName (c.gameObject.layer);
     switch (layerName)
     {
     case "Enemy":
         if( colliderIdList.Contains(c.GetInstanceID() ) )
         {
             return;
         }
         c.BroadcastMessage("Damage");
         //if( !isMultiHit )
         colliderIdList.Add (c.GetInstanceID());
         break;
     case "EnemyBullet":
         Destroy(c.gameObject);
         break;
     default:
         break;
     }
 }
开发者ID:k-yokozawa,项目名称:Unity_STG,代码行数:21,代码来源:SwordBullet.cs

示例4: DodgeBullet

    // Esquive des tirs du joueur
    private void DodgeBullet()
    {
        detectedBullet = Physics2D.OverlapArea (new Vector2 (myTransform.position.x - 1, myTransform.position.y + 0.5f), new Vector2 (myTransform.position.x - 2.5f, myTransform.position.y - 1), playerMask);

        // Si une balle entre dans la zone derrière la poule
        if (detectedBullet != null && detectedBullet.CompareTag("Bullet")) {
            // On retient la dernière balle prise en compte, pour éviter d'appeler en boucle la même fonction
            if (currentBulletID != detectedBullet.GetInstanceID ()) {
                currentBulletID = detectedBullet.GetInstanceID ();
                entryTime = TimeManager.time; // On retient le moment de l'entrée dans la zone, pour reset au bout de 2sec si jamais il ne se passe rien (voir plus bas)

                // On compare à la probabilité d'esquiver
                if (Random.Range(0f, 1f) < dodgeSkill) {
                    // On ajuste la puissance du saut en fonction du lieu d'impact de la balle
                    float powerJump = Mathf.Clamp(detectedBullet.transform.position.y, 1.5f, 2);
                    // On fait sauter la poule
                    myRb.velocity = new Vector2 (myRb.velocity.x, powerJump * jumpHeight);
                }
            }
        }

        if (TimeManager.time > entryTime + 2) {
            currentBulletID = 0;
        }
    }
开发者ID:lpointet,项目名称:runblobby,代码行数:26,代码来源:Enemy0102.cs

示例5: StopTrackingCollider

    /// <summary>
    /// Stop tracking the Collider2D.
    /// </summary>
    /// <param name="collider">The Collider2D to stop tracking.</param>
    public void StopTrackingCollider(Collider2D collider)
    {
        if(!trackedColliders.Contains(collider))
            return;

        trackedColliders.Remove(collider);
        TrackedColliderDictionary.Remove(collider.GetInstanceID());
    }
开发者ID:ZachWatkins,项目名称:Jello-Physics,代码行数:12,代码来源:JelloWorld.cs

示例6: StartTrackingCollider

    /// <summary>
    /// Start tracking the Collider2D.
    /// Adds it to the JelloWorld.trackedColliders list and JelloWorld.TrackedColliderDictionary.
    /// </summary>
    /// <param name="collider">The Collider2D to start tracking.</param>
    /// <param name="colliderInfo">The SupplementaryColliderInfo that describes the now tracked Collider2D.</param>
    /// <param name="jelloBody">The JelloBody, if any, the Collider2D belongs to.</param>
    /// <returns>Whether the collider is already being tracked. True if already being tracked, false if not.</returns>
    public bool StartTrackingCollider(Collider2D collider, out SupplementaryColliderInfo colliderInfo, JelloBody jelloBody = null)
    {
        if(trackedColliders.Contains(collider))
        {
            colliderInfo = World.TrackedColliderDictionary[collider.GetInstanceID()];
            return true;
        }

        trackedColliders.Add (collider);
        colliderInfo = new SupplementaryColliderInfo(collider, jelloBody);
        TrackedColliderDictionary.Add (collider.GetInstanceID(), colliderInfo);
        return false;
    }
开发者ID:ZachWatkins,项目名称:Jello-Physics,代码行数:21,代码来源:JelloWorld.cs

示例7: OnTriggerExit2D

	void OnTriggerExit2D(Collider2D other) {
		Destroy (arrows[other.GetInstanceID()].gameObject, 0);
		arrows.Remove (other.GetInstanceID ());
	}
开发者ID:LatexBotox,项目名称:SPACE,代码行数:4,代码来源:Radar.cs

示例8: OnTriggerEnter2D

 void OnTriggerEnter2D(Collider2D c)
 {
     isCollided(c.GetInstanceID(), c.gameObject);
     //Debug.Log("Enter "+this.gameObject.GetInstanceID() + " " +c.gameObject.GetInstanceID());
     //transform.position = new Vector3(0, -100, 0);
 }
开发者ID:kyung01,项目名称:UnityDemo2DPhysics,代码行数:6,代码来源:DeformableSpriteApplier.cs

示例9: GrabFunction

    private void GrabFunction(Collider2D other)
    {
        #region Cancel grab if one of these conditions is true (id, dist, yUpSpeed)

        // The id is used to make sure it can actually leave the grab state
        // and not regrab immediately
        int id = other.GetInstanceID();

        if (id == lastGrabbedID)
            return;

        // Makes sure its not to far down?
        float yDist = Grab.position.y - other.transform.position.y;

        if (yDist + GrabSettings.GrabMinNegYDist < 0)
            return;

        // If the upvelocity is too high, it will pass till falling down
        if (rigid.velocity.y > GrabSettings.MaxYVelocity)
            return;

        #endregion

        // Grab the object by translation
        Vector3 relPos = other.transform.position - tr.position;
        float dir = Mathf.Sign(relPos.x);

        Vector3 offset = GrabOffset;
        offset.x *= dir;
        Vector3 newPos = other.transform.position - offset;

        tr.position = newPos;

        // Change the state
        SetState(PlayerState.Grabbing);
        lastGrabbedID = id;

        // Can walljump in any direction after grabbing
        resetWallJump();

        // Make sure the animation clip is facing the right direction
        CheckFlipBy(dir);
    }
开发者ID:Bahamutho,项目名称:GJ01-Jazz-Climbing,代码行数:43,代码来源:PlatformerPhysics.cs


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