本文整理汇总了C#中Collider.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Collider.GetType方法的具体用法?C# Collider.GetType怎么用?C# Collider.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collider
的用法示例。
在下文中一共展示了Collider.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMass
public static float GetMass(Collider collider,float density = 1){
float volume = 0;
float mass = 0;
if(collider.GetType() == typeof(SphereCollider)){
volume = (collider.bounds.size.x * Mathf.PI)/6;
}else if(collider.GetType() == typeof(CapsuleCollider)){
volume = ((Mathf.PI * collider.bounds.size.x * collider.bounds.size.y) * collider.bounds.size.z)/4;
}else{
volume = collider.bounds.size.x * collider.bounds.size.y * collider.bounds.size.z;
}
mass = (density * volume)/10;
return mass;
}
示例2: OnTriggerStay
void OnTriggerStay(Collider col)
{
if (col.GetType() != typeof(SphereCollider) && !col.CompareTag("Terrain"))
{
isColliding = true;
}
}
示例3: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.GetType() == typeof(CapsuleCollider)) {
charactersEnding[other.name] = true;
CheckEndOfAllCharacters();
}
}
示例4: OnTriggerEnter
void OnTriggerEnter(Collider projectile)
{
if(projectile.GetType() == typeof(SphereCollider))
{
//bomb!!!
Vector3 houseTransform = thisHouse.transform.position;
Quaternion houseRotatoin = thisHouse.transform.rotation;
switch(targetType)
{
case TargetType.present:
//present was wanted
//lose points!
scoreController.addScore(-30);
//destroy house!!
GameObject.Destroy(thisHouse);
Instantiate(houseExplosion, houseTransform, houseRotatoin);
break;
case TargetType.bomb:
//bomb was wanted
//get points!
scoreController.addScore(10);
//destroy house
GameObject.Destroy(thisHouse);
Instantiate(houseExplosion, houseTransform, houseRotatoin);
break;
}
}
}
示例5: OnTriggerExit
void OnTriggerExit(Collider hitObject)
{
if (hitObject.GetType() == typeof(BoxCollider) && hitObject.CompareTag("Enemy"))
{
enemiesInMeleeRange.Remove(hitObject.gameObject);
}
}
示例6: OnTriggerEnter
void OnTriggerEnter(Collider obj)
{
if(obj.gameObject.tag == "Enemy" && obj.GetComponent<BossAI>() == bossAI && (typeof(SphereCollider) != obj.GetType ()) && isCollectableByBoss)
{
Debug.Log("Collision entre la Flesh et le boss");
Destroy(this.gameObject);
}
}
示例7: OnTriggerEnter
void OnTriggerEnter(Collider obj)
{
if(obj.gameObject.tag == "Enemy" && (typeof(SphereCollider) != obj.GetType ()))
{
Destroy(this.gameObject);
obj.GetComponentInParent<EnemyObject>().enemy.removeHP(player.attack/2);
obj.gameObject.GetComponent<EnemyObject>().afficherVie = true;
}
}
示例8: OnTriggerEnter
void OnTriggerEnter (Collider other){
if (other.transform.parent) {
if (other.transform.parent.GetComponent<CharacterStats>() && other.gameObject.transform.parent.tag != transform.parent.tag && !enemies.Contains (other)) {
if (other.GetType () == typeof(BoxCollider)) {
enemies.Add (other);
}
}
}
}
示例9: OnTriggerEnter
void OnTriggerEnter (Collider coll)
{
if (coll.name == "Zombie" && coll.GetType() == typeof(CapsuleCollider))
{
GameObject go = coll.collider.gameObject;
mAI other = (mAI)go.GetComponent (typeof(mAI));
other.hurt();
}
//Destroy (gameObject, 0.3f);
}
示例10: ClosestPointOnSurface
public static bool ClosestPointOnSurface(Collider collider, Vector3 to, float radius, out Vector3 closestPointOnSurface)
{
if (collider is BoxCollider)
{
closestPointOnSurface = SuperCollider.ClosestPointOnSurface((BoxCollider)collider, to);
return true;
}
else if (collider is SphereCollider)
{
closestPointOnSurface = SuperCollider.ClosestPointOnSurface((SphereCollider)collider, to);
return true;
}
else if (collider is CapsuleCollider)
{
closestPointOnSurface = SuperCollider.ClosestPointOnSurface((CapsuleCollider)collider, to);
return true;
}
else if (collider is MeshCollider)
{
RPGMesh rpgMesh = collider.GetComponent<RPGMesh>();
if (rpgMesh != null)
{
closestPointOnSurface = rpgMesh.ClosestPointOn(to, radius, false, false);
return true;
}
BSPTree bsp = collider.GetComponent<BSPTree>();
if (bsp != null)
{
closestPointOnSurface = bsp.ClosestPointOn(to, radius);
return true;
}
BruteForceMesh bfm = collider.GetComponent<BruteForceMesh>();
if (bfm != null)
{
closestPointOnSurface = bfm.ClosestPointOn(to);
return true;
}
}
else if (collider is TerrainCollider)
{
closestPointOnSurface = SuperCollider.ClosestPointOnSurface((TerrainCollider)collider, to, radius, false);
return true;
}
Debug.LogError(string.Format("{0} does not have an implementation for ClosestPointOnSurface; GameObject.Name='{1}'", collider.GetType(), collider.gameObject.name));
closestPointOnSurface = Vector3.zero;
return false;
}
示例11: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.tag == "Player" && (other.GetType() == typeof(CapsuleCollider))) {
if (CheckIfCharacterInSight(other.gameObject)) {
List <object> info = new List<object>();
object dmgObject = damage;
info.Add(dmgObject);
info.Add(caster);
other.gameObject.SendMessageUpwards("TakeDamage", info);
}
}
}
示例12: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other is CharacterController) {
CharacterController A = (CharacterController)other;
A.transform.forward = - this.transform.forward;
//A.Move(new Vector3(0,20,-10));
print ("Collision by: "+other.GetType().ToString()+" ... End of text");
}
}
示例13: OnTriggerStay
void OnTriggerStay(Collider projectile)
{
if(!triggered && projectile.rigidbody.velocity.magnitude <= 0.01)
{
if(projectile.GetType() == typeof(BoxCollider) && targetType == TargetType.present)
{
//present was correctly received!
triggered = true;
//add points
scoreController.addScore(10);
//remove trigger
GameObject.Destroy(gameObject);
}
else if(projectile.GetType() == typeof(BoxCollider) && targetType == TargetType.bomb)
{
//present was incorrectly recieved!
triggered = true;
//add points
scoreController.addScore(-10);
//remove trigger
GameObject.Destroy(gameObject);
}
}
}
示例14: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Tower" && !other.GetType().ToString().Equals("UnityEngine.SphereCollider"))
{
var tower = GameObject.FindGameObjectWithTag("Player").GetComponent<TowerControl>();
tower.Placeable = false;
tower.collided.Add(this.gameObject);
var renderers = other.gameObject.GetComponentsInChildren<Renderer>();
foreach (var render in renderers)
{
render.material.color = Color.red;
}
}
}
示例15: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (!triggered) {
if (other.tag == "Player" && other.GetType() == typeof(CapsuleCollider)) {
StartCoroutine(GiveTextToHandler());
if (uiEventSendMessage != "") {
GameObject.Find("TutorialUIEvents").SendMessage(uiEventSendMessage);
}
if (flashMessage == "FlashHealth" ) {
GameObject.Find("UserInterface").GetComponent<UserInterfaceManager>().FlashHealth("Character1", 3);
} else if (flashMessage == "FlashMovement") {
GameObject.Find("UserInterface").GetComponent<UserInterfaceManager>().FlashMovement("Character1", 3);
} else if (flashMessage == "FlashActionPoints") {
GameObject.Find("UserInterface").GetComponent<UserInterfaceManager>().FlashActionPoints("Character1", 3);
}
triggered = true;
}
}
}