本文整理汇总了C#中Collision类的典型用法代码示例。如果您正苦于以下问题:C# Collision类的具体用法?C# Collision怎么用?C# Collision使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Collision类属于命名空间,在下文中一共展示了Collision类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if(side==BulletSide.FRIENDLY)
{
if(col.gameObject.tag==TagsStorage.ABIL_SHIELD)
deactivate();
if(col.gameObject.tag==TagsStorage.ENEMY_TAG)
{
col.gameObject.GetComponent<EnemySpaceship>().Attacked(damage);
deactivate();
}
}
if(side==BulletSide.ENEMY)
{
if(col.gameObject.tag==TagsStorage.FRIENDLY_TAG)
{
col.gameObject.GetComponent<FriendlySpaceship>().Attacked(damage);
deactivate();
}
if(col.gameObject.tag==TagsStorage.ABIL_SHIELD)
deactivate();
}
if(col.gameObject.tag==TagsStorage.ASTEROID_TAG)
deactivate();
}
开发者ID:tiempo8,项目名称:spacetactics20,代码行数:28,代码来源:BulletContainer.cs
示例2: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if (col.gameObject.name == "Wall")
{
Destroy (gameObject);
}
else if (col.gameObject.name == "BlueVirus"){
bVirus = col.gameObject.GetComponent<BlueVirus>();
bVirus.takeDamage (1,1);
Destroy (gameObject);
}
else if (col.gameObject.name == "RedVirus"){
Destroy (gameObject);
}
else if (col.gameObject.name == "GreenVirus"){
gVirus = col.gameObject.GetComponent<GreenVirus>();
gVirus.takeDamage (1,1);
Destroy (gameObject);
}else if(col.gameObject.name == "Boss"){
boss = col.gameObject.GetComponent<BossScript>();
boss.takeDamage(1, 1);
Destroy(gameObject);
}
}
开发者ID:TStream,项目名称:MiniPhD,代码行数:25,代码来源:LazerBeam.cs
示例3: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == "Ammo")
{
vie--;
if (vie <= 0)
{
isDead = true;
anim.SetBool("isWalking", false);
anim.SetBool("weapon", false);
anim.SetBool("isDead", true);
Player.score++;
if (!isDead)
{
GameObject.Find("score").GetComponent<Text>().text = "Score : " + Player.score;
}
isDead = true;
if (Application.loadedLevelName == "Jeu1")
{
Application.LoadLevel("Jeu2");
}
}
}
}
开发者ID:KickAss42,项目名称:Projet-SurvivAll,代码行数:25,代码来源:Mob.cs
示例4: OnCollisionEnter
// Handle all collisions
void OnCollisionEnter(Collision collision)
{
if (gameObject.name == "1_Player_East")
{
PlayerPrefs.SetInt("NumPlayers", 1);
Application.LoadLevel(2);
}
if (gameObject.name == "1_Player_West")
{
PlayerPrefs.SetInt("NumPlayers", 1);
Application.LoadLevel(3);
}
if (gameObject.name == "2_Player_East")
{
PlayerPrefs.SetInt("NumPlayers", 2);
Application.LoadLevel(2);
}
if (gameObject.name == "2_Player_West")
{
PlayerPrefs.SetInt("NumPlayers", 2);
Application.LoadLevel(3);
}
if (collision.gameObject.GetComponent(typeof(SnowBall)) != null )
{
if( (collision.gameObject.GetComponent(typeof(SnowBall)) as SnowBall).BallLauncher == SnowBall.Launcher.Enemy)
{
GUIManager.currentScore = GUIManager.currentScore - HitPenalty;
if (PlayerPrefs.GetString("SelectedGameMode").Equals("HardMode"))
{
GameController.lives--;
}
}
}
}
开发者ID:qimmer,项目名称:mta13341,代码行数:36,代码来源:Player.cs
示例5: OnCollisionEnter
void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag == "BallTag")
{
GameOver(collision);
}
}
开发者ID:SebastiaanBuwalda,项目名称:3DPinballUnity,代码行数:7,代码来源:DeathPit.cs
示例6: OnCollisionEnter
public void OnCollisionEnter(Collision col)
{
if(col.gameObject.transform.position.x < transform.position.x)
SendMessageUpwards("RotateDoorClock");//, col.gameObject.rigidbody.velocity.magnitude);
else
SendMessageUpwards("RotateDoorUnClock");
}
开发者ID:jonwa,项目名称:Project-Alix,代码行数:7,代码来源:Door.cs
示例7: OnCollisionEnter
void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag == "Bullet")
{
GetComponent<NavMeshAgent>().Warp(begin);
}
}
开发者ID:benjaml,项目名称:PathfindingToolUnity,代码行数:7,代码来源:Poulpe2.cs
示例8: OnCollisionEnter
void OnCollisionEnter(Collision collision)
{
//Debug.Log(collision.relativeVelocity.magnitude);
if (collision.relativeVelocity.magnitude > 2){
audio.Play();
}
}
开发者ID:Ghost---Shadow,项目名称:UnityBowling,代码行数:7,代码来源:BowlingPin.cs
示例9: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if(particule)
GameObject.Instantiate(particule, transform.position, Quaternion.identity);
//on inflige des degas au ennemis si il sont dans la zone
EnemyController[] targets = FindObjectsOfType(System.Type.GetType("EnemyController")) as EnemyController[];
for (int i=0; i<targets.Length; i++)
{
Vector3 distance = transform.position-targets[i].transform.position;
if(distance.magnitude <= m_distance)
{
float damage = -m_damage + (-m_damage)/100 * targets[i].getSkillManager().getMagicResistance();
//gestion de la furie
if(m_furie)
damage += damage/100 * m_damageFurie;
//gestion des critique
if(m_factorCritique/100 < Random.value)
damage *= 2;
targets[i].healthUpdate(damage);
}
}
Destroy(this.gameObject);
}
开发者ID:TheDeadMemoriesTeam,项目名称:TheDeadMemories,代码行数:25,代码来源:SuperSkillController.cs
示例10: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if (col.collider.CompareTag("Player") || col.collider.CompareTag("Item"))
{
isHurt = true;
}
}
开发者ID:doraoam,项目名称:Pollo-Roller,代码行数:7,代码来源:HeadShot.cs
示例11: OnCollisionEnter
void OnCollisionEnter(Collision c)
{
if (c.gameObject == GameObject.FindWithTag ("Boss"))
SetPv (5);
if (c.gameObject.tag == "fireennemy")
SetPv (1);
}
开发者ID:LMAdrien,项目名称:SpaceInvader,代码行数:7,代码来源:PlayerMove.cs
示例12: OnCollisionEnter
void OnCollisionEnter(Collision collision)
{
if(collision.collider.tag == "KillBox") {
Destroy(gameObject);
MultiManager.Instance.Board.DropHealth();
}
}
开发者ID:jrivera777,项目名称:VoxelSlayer,代码行数:7,代码来源:Voxel.cs
示例13: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if (!roadcols.Contains(col.collider.name))
{
if (col.collider.name.Equals("Road_Coll02_Side") && TriggerTimer.roundNo > rc2s)
{
Debug.Log("triggered");
rc2s++;
}
else
{
if (col.collider.name.Equals("Road_Coll_Side") && RoadCollHelper.inTrigger)
{
//do nothing
}
else
{
Debug.Log(col.collider.name);
Debug.Log(col.relativeVelocity.magnitude);
velo.Add(col.relativeVelocity.magnitude);
TriggerTimer.collisions++;
}
}
}
}
开发者ID:Rickyfox,项目名称:DSGG_new,代码行数:27,代码来源:CollisionHandler.cs
示例14: OnCollisionEnter
void OnCollisionEnter(Collision other)
{
if (other.gameObject.layer == LayerMask.NameToLayer("TrackWall"))
{
// Get Collision impact
float impact = Vector3.Dot(other.contacts[0].normal, other.relativeVelocity);
float hitDot = Vector3.Dot(other.contacts[0].normal, transform.forward);
if (Mathf.Abs(impact) > 1 && hitDot < 0.1f)
{
// Zero out relative Z velocity
r.PlayOneShot(r.settings.SFX_WALLHIT);
Vector3 lv = transform.InverseTransformDirection(r.body.velocity);
lv.y = 0;
lv.z = 0;
Vector3 wv = transform.TransformDirection(lv);
r.body.velocity = wv;
// Reduce engine power and thrust
enginePower *= 0.2f;
engineThrust *= 0.2f;
// Push ship away from wall
Vector3 dir = other.contacts[0].normal;
dir.y = 0;
r.body.AddForce(dir * Mathf.Abs(impact), ForceMode.Impulse);
// Spawn hit particle
GameObject particle = Instantiate(Resources.Load("Particles/CollisionHit") as GameObject) as GameObject;
particle.transform.position = other.contacts[0].point;
particle.transform.forward = -transform.forward;
// Ship take damage
r.shield -= Mathf.Abs(impact * 2);
}
}
if (other.gameObject.tag == "Ship")
{
//r.PlayOneShot(SHIP2SHIP SOUND);
// Stop Bounce
Vector3 lv = transform.InverseTransformDirection(r.body.velocity);
lv.y = 0;
Vector3 wv = transform.TransformDirection(lv);
if (!isShipGrounded)
r.body.velocity = wv;
// Slow ship down slightly
enginePower *= 0.8f;
engineThrust *= 0.8f;
// Push away from other ship
Vector3 dir = other.contacts[0].normal;
dir.y = 0;
r.body.AddForce(dir * 4, ForceMode.Impulse);
}
}
开发者ID:dreadofmondays,项目名称:BallisticNG,代码行数:60,代码来源:ShipSim.cs
示例15: OnCollisionEnter
void OnCollisionEnter(Collision collision)
{
if (collision.collider.gameObject.tag.Equals("Player"))
{
collision.collider.rigidbody.AddForce(Vector3.forward * 100);
}
}
开发者ID:tedajax,项目名称:puzzly,代码行数:7,代码来源:ClearDoorway.cs
示例16: OnCollide
virtual protected void OnCollide( Collision collision )
{
if ( collision.gameObject.CompareTag( "Player" ) ) return;
// Kill enemy
if ( ( !HasHitUnit ) && ( collision != null ) && ( collision.transform.gameObject.layer == LayerMask.NameToLayer( "Enemy" ) ) )
{
EnemyUnitBaseScript enemyunit = collision.transform.GetComponent<EnemyUnitBaseScript>();
if ( enemyunit )
{
enemyunit.Die_Killed();
}
Destroy( collision.transform.gameObject );
// Flag as hit so no other units are destroyed this frame
HasHitUnit = true;
// Virtual override for child classes
OnUnitHit( collision );
}
// Kill protectile
Destroy( transform.parent.gameObject );
// Spawn projectile death effect
GameObject effect = (GameObject) Instantiate( DeathEffectPrefab, transform.position, Quaternion.Euler( Vector3.zero ) );
effect.transform.SetParent( GameObject.Find( "GameObjectContainer" ).transform );
}
开发者ID:johnjoemcbob,项目名称:coolguysmakegames,代码行数:29,代码来源:WeaponProjectileBaseScript.cs
示例17: OnCollisionEnter
void OnCollisionEnter(Collision theCollision)
{
CarDriver otherObjectsScript = theCollision.gameObject.GetComponent<CarDriver> ();
if(otherObjectsScript != null)
otherObjectsScript.Respawn();
}
开发者ID:GoldBARR93,项目名称:SimpleCarCourse,代码行数:7,代码来源:ResetFromCrash.cs
示例18: OnCollisionEnter
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.name == "Player")
{
clearText.SetActive(true);
}
}
开发者ID:keijiro,项目名称:TsudaUnity,代码行数:7,代码来源:Medal.cs
示例19: OnCollisionEnter
void OnCollisionEnter(Collision collision)
{
if(runnerController!=null)
{
runnerController.Runnercollision(collision);
}
}
开发者ID:HugoPourrierNunez,项目名称:2016_3A_UNITY_pourriernunez,代码行数:7,代码来源:RunnerCollisionScript.cs
示例20: OnCollisionEnter
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == "Projectile")
{
explode = true;
}
}
开发者ID:gorco,项目名称:MissionDemolition,代码行数:7,代码来源:Wall_Stone_Destuctible.cs
注:本文中的Collision类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论