当前位置: 首页>>代码示例>>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;未经允许,请勿转载。