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


C# UnityEngine.ControllerColliderHit類代碼示例

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


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

示例1: OnControllerColliderHit

    void OnControllerColliderHit(ControllerColliderHit hit)
    {
        Rigidbody body = hit.collider.attachedRigidbody;

        // no rigidbody
        if (body == null || body.isKinematic)
            return;

        // We dont want to push objects below us

        if (hit.moveDirection.y < -0.5)
        {
            //platform = hit.transform;
            return;
        }

        // Calculate push direction from move direction,
        // we only push objects to the sides never up and down
        // if you wanted up and down pushing, change 0 to hit.moveDirection.y
        Vector3 pushDir = new Vector3(hit.moveDirection.x, 0, hit.moveDirection.z);

        // If you know how fast your character is trying to move,
        // then you can also multiply the push velocity by that.
        // Apply the push and decrease speed to 25% of the normal walk speed.
        body.velocity = (pushDir * Speed)/4;
    }
開發者ID:pointNineStudios,項目名稱:Dreamora,代碼行數:26,代碼來源:PlatformerController.cs

示例2: OnControllerColliderHit

 /*////////////////////////////////////*/
 //Fonction des Dommages
 /*////////////////////////////////////*/
 void OnControllerColliderHit(ControllerColliderHit collision)
 {
     if(collision.gameObject.tag == "Player")
     {
         animator.SetBool("Hit", true);
     }
 }
開發者ID:KakaSho,項目名稱:InvadersFromFarAway,代碼行數:10,代碼來源:LocomotionPlayer.cs

示例3: OnControllerColliderHit

 void OnControllerColliderHit(ControllerColliderHit coll)
 {
     if(coll.gameObject.tag == damageTag)
     {
         myKillable.Damage(damageRate);
     }
 }
開發者ID:AVataRR626,項目名稱:https---github.com-AVataRR626-Goat_Mage,代碼行數:7,代碼來源:QSIKillableTouchDamage.cs

示例4: OnControllerColliderHit

 void OnControllerColliderHit(ControllerColliderHit other)
 {
     if (other.gameObject.GetComponent<DeathOnContact>() != null)
     {
         Kill();
     }
 }
開發者ID:MatthewNelson2015,項目名稱:UND-Capstone-Game-2014-2015,代碼行數:7,代碼來源:Manager.cs

示例5: OnControllerColliderHit

    public void OnControllerColliderHit(ControllerColliderHit hit)
    {

       


    }
開發者ID:talhahasanzia,項目名稱:MazeBot-Old-Unity5.0,代碼行數:7,代碼來源:Objective.cs

示例6: OnControllerColliderHit

    void OnControllerColliderHit(ControllerColliderHit hit)
    {
        if (hit.gameObject.Equals (lastColl) || isAnimation) {
            //Debug.Log("Nothing new: " + hit.gameObject.name);
            return;
        }
        Debug.Log ("Collision with: " + hit.gameObject);
        lastColl = hit.gameObject;
        transform.parent = lastColl.transform; // Aneinander kleben

        if (hit.gameObject.tag == "Finish")
            Application.LoadLevel (1);
        else if (hit.gameObject.tag == "Respawn") {
            Application.LoadLevel (0);
        } else if (hit.gameObject.tag == "Weiß" || hit.gameObject.tag == "Schwarz") {
            FeldControl2 fc = hit.gameObject.GetComponent<FeldControl2>();
            Debug.Log("Auf Schachbrett " + (1 + fc.Board) + " auf Feld " + fc.Field);
            PosText.text = "B: " + (fc.Board + 1) + " - P: " + fc.Field;
            if (!cBretterWeiß.AnimInProgress && !cBretterSchwarz.AnimInProgress) {
                if (hit.gameObject.tag == "Weiß") {
                    transform.parent = BretterWeiß.transform;
                    cBretterWeiß.BeginAnimation();
                } else {
                    transform.parent = BretterSchwarz.transform;
                    cBretterSchwarz.BeginAnimation();
                }
            }
        } else {
            Debug.Log("Collission not recognized: " + lastColl);
        }
        grounded = true;
    }
開發者ID:fr34q,項目名稱:MLChess,代碼行數:32,代碼來源:PlayerController2.cs

示例7: OnControllerColliderHit

 void OnControllerColliderHit(ControllerColliderHit hit)
 {
     if(hit.gameObject.tag == "boulder")
     {
         hit.rigidbody.AddForce(transform.forward * speed);
     }
 }
開發者ID:kaancelen,項目名稱:unity_volume,代碼行數:7,代碼來源:CharacterMovement.cs

示例8: OnControllerColliderHit

 void OnControllerColliderHit(ControllerColliderHit hit)
 {
     if(hit.transform.tag == "Building")
     {
         GameOver();
     }
 }
開發者ID:GlitchBoss,項目名稱:Cops-N--Crooks,代碼行數:7,代碼來源:PlayerController.cs

示例9: OnControllerColliderHit

    void OnControllerColliderHit(ControllerColliderHit hit)
    {
        //Debug.Log ("detect a controller collider hit");
        Rigidbody body = hit.collider.attachedRigidbody;
        Vector3 pushDir;

        //Debug.Log ("body = " + (body==null));
        if (body!=null)
            //Debug.Log ("body = " + (body.isKinematic));
        // no rigidbody
        if (body == null || body.isKinematic) { return; }

        //Debug.Log (hit.moveDirection);
        // We dont want to push objects below us
        if (hit.moveDirection.y < -0.3) { return; }

        if (body.tag == "Door") {
            //Debug.Log("Pushing door");
            body.AddForce(-transform.forward * 1000f, ForceMode.Acceleration);
            body.useGravity = true;
        } else {
            // Calculate push direction from move direction,
            // we only push objects to the sides never up and down
            pushDir = new Vector3 (hit.moveDirection.x, 0, hit.moveDirection.z);

            // If you know how fast your character is trying to move,
            // then you can also multiply the push velocity by that.

            // Apply the push
            body.velocity = pushDir * pushPower;
        }
    }
開發者ID:hannahjgb,項目名稱:AdventureGameFiles,代碼行數:32,代碼來源:PlayerPhysics.cs

示例10: CollisionNodeInfo

 public CollisionNodeInfo(CollisionNodeToggler hitNode, Collider colliderObj, Collision collisionObj, ControllerColliderHit cchit)
 {
     this.hitNode = hitNode;
     collider = colliderObj;
     collision = collisionObj;
     controllerColliderHit = cchit;
 }
開發者ID:WaylandGod,項目名稱:EasyMotion2D.Runtime,代碼行數:7,代碼來源:CollisionNodeToggler.cs

示例11: OnControllerColliderHit

    void OnControllerColliderHit(ControllerColliderHit hit)
    {
        if (hit.gameObject.name == "Spaceship")
        {
            hit.gameObject.SendMessage("EnterSpaceship", SendMessageOptions.DontRequireReceiver);
            return;
        }

        Rigidbody body = hit.collider.attachedRigidbody;
        // no rigidbody
        if (body == null || body.isKinematic)
            return;

        // Only push rigidbodies in the right layers
        int bodyLayerMask = 1 << body.gameObject.layer;
        if ((bodyLayerMask & pushLayers.value) == 0)
            return;

        // We dont want to push objects below us
        if (hit.moveDirection.y < -0.3)
            return;

        // Calculate push direction from move direction, we only push objects to the sides
        // never up and down
        Vector3 pushDir = new Vector3(hit.moveDirection.x, 0, hit.moveDirection.z);

        // push with move speed but never more than walkspeed
        body.velocity = pushDir * pushPower * Mathf.Min (controller.GetSpeed (), controller.movement.walkSpeed);
    }
開發者ID:dennisfischer,項目名稱:UnityLerpzPlatformerLevel,代碼行數:29,代碼來源:PlatformerPushBodies.cs

示例12: handleCollision

 public bool handleCollision(ControllerColliderHit hit, Rigidbody body, float force)
 {
     Vector3 pushDir = new Vector3 (hit.moveDirection.x, 0, hit.moveDirection.z);
     //		body.velocity = pushDir * force;
     body.AddForce (pushDir * force);
     return false;
 }
開發者ID:hannahjgb,項目名稱:AdventureGameFiles,代碼行數:7,代碼來源:PlayerPushHandler.cs

示例13: OnControllerColliderHit

	void OnControllerColliderHit(ControllerColliderHit hit){
		GameObject go = GameObject.FindGameObjectWithTag ("Player");
		MainPjMovement target = go.GetComponent ("MainPjMovement") as MainPjMovement;

		if (target.getHP () != target.getMAXHP ()) {
			if (hit.gameObject.tag == "BigHealPotion") {
				PJAudio.DrinkPotion();
				target.increaseHeal (200);
				Destroy (hit.gameObject);
			}
			if (hit.gameObject.tag == "LittleHealPotion") {
				PJAudio.DrinkPotion();
				target.increaseHeal (100);
				Destroy (hit.gameObject);
			}
		}
		if (target.getMP () != target.getMAXMP ()) {
			if (hit.gameObject.tag == "BigManaPotion") {
				target.increaseMana (200);
				Destroy (hit.gameObject);
			}
			if (hit.gameObject.tag == "BigManaPotion") {
				target.increaseMana (100);
				Destroy (hit.gameObject);
			}
		}
		if (hit.gameObject.tag == "Shield") {
			target.setShield(true);
			
			Destroy(hit.gameObject);
		}
	}
開發者ID:eloipuertas,項目名稱:ES2014B,代碼行數:32,代碼來源:EnvController.cs

示例14: OnControllerColliderHit

    void OnControllerColliderHit(ControllerColliderHit hit)
    {
        Rigidbody body = hit.collider.attachedRigidbody;
        // no rigidbody
        if (body == null || body.isKinematic)
            return;

        // Only push rigidbodies in the right layers
        var bodyLayerMask = 1 << body.gameObject.layer;
        if ((bodyLayerMask & pushLayers.value) == 0)
            return;

        // We dont want to push objects below us
        //if (hit.moveDirection.y < -0.3)
        //    return;

        // Calculate push direction from move direction, we only push objects to the sides
        // never up and down
        //Vector3 pushDir = new Vector3(hit.moveDirection.x, 0, hit.moveDirection.z);

        // push with move speed but never more than walkspeed
        //body.velocity = pushDir * pushPower * Mathf.Min (controller.GetSpeed (), controller.movement.walkSpeed);
        body.AddForceAtPosition(hit.normal*(-pushPower), hit.point);
        //print(hit.normal);
    }
開發者ID:Seraphli,項目名稱:TheInsectersWar,代碼行數:25,代碼來源:PlatformerPushBodies.cs

示例15: OnControllerColliderHit

 //OnControllerColliderHit(ControllerColliderHit hit)
 void OnControllerColliderHit(ControllerColliderHit hit)
 {
     if (hit.transform.tag == "shark"){
         Destroy(gameObject);
         Application.LoadLevel(Application.loadedLevel);
     }
 }
開發者ID:johste93,項目名稱:UnityProjects,代碼行數:8,代碼來源:EatsPlayer.cs


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