• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# UnityEngine.ControllerColliderHit类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UnityEngine.ControllerColliderHit的典型用法代码示例。如果您正苦于以下问题:C# ControllerColliderHit类的具体用法?C# ControllerColliderHit怎么用?C# ControllerColliderHit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ControllerColliderHit类属于UnityEngine命名空间,在下文中一共展示了ControllerColliderHit类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: OnCharacterCollided

        public override void OnCharacterCollided(ControllerColliderHit hit, Transform other)
        {
            base.OnCharacterCollided(hit, other);

            if (Colliding)
                return;

            //check if hit point beneath player
            var dir = (hit.point - other.position).normalized;
            if (dir.y < -0.9)
                CollisionType = DaggerfallAction.TriggerTypes.WalkOn;
            else
            {
                if (thisAction.TriggerFlag == DaggerfallConnect.DFBlock.RdbTriggerFlags.Collision01)
                {
                    Vector3 origin = new Vector3(hit.controller.transform.position.x, hit.controller.transform.position.y - hit.controller.height / 2, hit.controller.transform.position.z);
                    Ray ray = new Ray(origin, Vector3.down);
                    RaycastHit hitInfo;

                    //if hit not below controller, see if player standing on this action object w/ raycast & if action flag is Collision01 (walk on)
                    //set trigger type & activate if so - to avoid player being able to push against wall to avoid
                    if (hit.collider.Raycast(ray, out hitInfo, hit.controller.skinWidth))
                        CollisionType = DaggerfallAction.TriggerTypes.WalkOn;
                    else
                        CollisionType = DaggerfallAction.TriggerTypes.WalkInto;
                }
                else
                    CollisionType = DaggerfallAction.TriggerTypes.WalkInto;

            }

            Colliding = true;
        }
开发者ID:Nystul-the-Magician,项目名称:daggerfall-unity,代码行数:33,代码来源:DaggerfallActionCollision.cs


示例17: OnControllerColliderHit

	void OnControllerColliderHit(ControllerColliderHit col){
		Debug.Log(col.gameObject.name);
		if(col.gameObject.tag == "Core"){
			score++;
			Destroy(col.gameObject);
		}
	}
开发者ID:1234224576,项目名称:UnityChallenge,代码行数:7,代码来源:AttackBot.cs


示例18: OnControllerColliderHit

    void OnControllerColliderHit(ControllerColliderHit hit)
    {
        GameObject body = hit.gameObject;
        switch (body.tag){
            case "Target":
            if(state == STATE.HOOKING && body.name ==hookTarget){
                state = STATE.STUCK;
                lastStuck = body.name;
                hookTarget = "";
                foreach(GameObject item in passedThrough)
                    item.collider.enabled = true;

                passedThrough.Clear ();
            }
            else{
                passedThrough.AddFirst(body);
                body.collider.enabled=false;
            }
            break;
            case "Platform":
                state = STATE.GROUNDED;
                break;
        }

          //  body.velocity = pushDir * pushPower;
    }
开发者ID:ordonak,项目名称:grappleGame,代码行数:26,代码来源:CharMoter.cs


示例19: ApplyHit

    void ApplyHit(ControllerColliderHit hit)
    {
        if (hit.normal.y > 0.7f) {
            Vector3 normalVelocity = Vector3.Project(move.velocity, Vector3.up);
            Vector3 tangentialVelocity = Vector3.ProjectOnPlane(move.velocity, Vector3.up);

            var movingSurface = hit.gameObject.GetComponentInParent<MovingSurface>();
            if (movingSurface == null) {
                tangentialVelocity = Vector3.zero;
            } else {
                Vector3 radiusVector = hit.point - movingSurface.transform.position;
                //Vector3 rotationVelocity = Vector3.Cross(movingSurface.currentAngularVelocity * Mathf.Deg2Rad, radiusVector);

                //Vector3 localHitPoint = movingSurface.transform.InverseTransformPoint(hit.point);
                Vector3 nextRadiusVector = Quaternion.Euler(movingSurface.currentAngularVelocity * Time.fixedDeltaTime) * radiusVector;
                Vector3 rotationVelocity = (nextRadiusVector - radiusVector) / Time.fixedDeltaTime;

                //Debug.Log("movingSurface.currentAngularVelocity: " + movingSurface.currentAngularVelocity);
                //Debug.Log("rotationVelocity: " + rotationVelocity);

                Vector3 hitPointVelocity = movingSurface.currentVelocity + rotationVelocity;

                tangentialVelocity = hitPointVelocity;

                //Debug.Log("Final tangentialVelocity: " + tangentialVelocity);
            }

            move.velocity = normalVelocity + tangentialVelocity;

            move.angularVelocity = movingSurface != null ? movingSurface.currentAngularVelocity : Vector3.zero;
            //move.angularVelocity = move.angularVelocity.Change(x: 0, z: 0);
        }
    }
开发者ID:craus,项目名称:UnityTest,代码行数:33,代码来源:Grounder.cs


示例20: OnControllerColliderHit

 void OnControllerColliderHit(ControllerColliderHit hit)
 {
     if (hit.collider.gameObject.name == "Box")
     {
         Debug.Log("Collision!!!!!");
     }
 }
开发者ID:pj87,项目名称:PGK,代码行数:7,代码来源:CollisionWithCube.cs



注:本文中的UnityEngine.ControllerColliderHit类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UnityEngine.Coroutine类代码示例发布时间:2022-05-26
下一篇:
C# UnityEngine.ComputeBuffer类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap