本文整理汇总了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);
}
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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());
}
示例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;
}
示例7: OnTriggerExit2D
void OnTriggerExit2D(Collider2D other) {
Destroy (arrows[other.GetInstanceID()].gameObject, 0);
arrows.Remove (other.GetInstanceID ());
}
示例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);
}
示例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);
}