当前位置: 首页>>代码示例>>C#>>正文


C# Collider.ClosestPointOnBounds方法代码示例

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


在下文中一共展示了Collider.ClosestPointOnBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if(attack!=null){
         if(other.tag.Equals("Enemy")){
             attack.GetComponent<Attack>().enemyCollisionEnter(other.gameObject,other.ClosestPointOnBounds(transform.position));
         }else{
             attack.GetComponent<Attack>().otherCollisionEnter(other.gameObject,other.ClosestPointOnBounds(transform.position));
         }
     }
     if (debug != null) {
         debug.SetActive (true);
         wasEnabled = false;
     }
 }
开发者ID:JosepFloriach,项目名称:LightguardLegacy,代码行数:14,代码来源:AttackCollider.cs

示例2: OnTriggerEnterDown

    //
    // DOWN
    //
    public void OnTriggerEnterDown( Collider lockCollider,Collider other )
    {
        if ( downLock > 0 && findNearestCollider( other, whoDown ) )
        {
            if ( other.transform.position.x == whoDown.transform.position.x )
            {
                downLock = LOCK_TIME;
                return;
            }
        }

        //		if ( downLock > 0 )
        //			return;
        //
        //		if ( posDelta.z < 0 )
        {
            downLock = LOCK_TIME;
            whoDown = other;

            Vector3 up = other.ClosestPointOnBounds( target.position + (Vector3.forward * 100) );
            float dif =   (lockCollider.transform.position.z - lockCollider.bounds.extents.z) - up.z;
            downLimitZ =  target.position.z - dif;// - offset.z;// - dif;//(transform.position.x - (lockCollider.transform.position.x + lockCollider.bounds.extents.x)) + lockCollider.transform.localPosition.x;
            debugSelect[3] = other.gameObject;

        }
    }
开发者ID:nosfex,项目名称:aztec_treasure,代码行数:29,代码来源:FollowSmooth.cs

示例3: OnTriggerStay

 void OnTriggerStay(Collider collider)
 {
     if(collider.gameObject.layer.Equals(LayerMask.NameToLayer("Player")) && cooldownTimer>cooldown && isActiveAndEnabled){
         cooldownTimer = 0f;
         GameManager.playerController.getHurt(damage,collider.ClosestPointOnBounds(transform.position));
     }
 }
开发者ID:JosepFloriach,项目名称:LightguardLegacy,代码行数:7,代码来源:DamageOnCollide.cs

示例4: OnTriggerEnter

 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Enemy") {
         IAController enemy = other.GetComponent<IAController>();
         enemy.getHurt(damage,other.ClosestPointOnBounds(transform.position),true);
     }
 }
开发者ID:JosepFloriach,项目名称:LightguardLegacy,代码行数:7,代码来源:WeaponColider.cs

示例5: HandleResource

    public void HandleResource( Collider plantColl )
    {
        GameObject plant = plantColl.gameObject;
        if ( critter.gameObject.CompareTag("Herbivore") )  // Are we a Herbivore?
        {
            // Debug.Log("Weve hit a Plant!" + critter.ID.ToString());
            foreach ( int preyID in critter.preyList )
            {
                // Debug.Log("Looking for " + preyID.ToString() + " in " + plant.name);
                if ( plant.name.Contains( preyID.ToString() ) )
                {
                    if ( Random.value < .80f )
                    {
                        // Debug.Log("" + critter.ID.ToString() + " Nomm nomm " + plant.name);
                        critter.navMeshAgent.Stop();

                        Vector3 foragePoint = plantColl.ClosestPointOnBounds(critter.transform.position);
                        critter.navMeshAgent.SetDestination(foragePoint);
                        critter.navMeshAgent.Resume();
                        ToForageState();
                    }
                }
            }
        }
    }
开发者ID:ltg-uic,项目名称:Wallcology-Simulator,代码行数:25,代码来源:EnterState.cs

示例6: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        ObstaclePropertyInfo infoScript = other.gameObject.GetComponent<ObstaclePropertyInfo>();

        //如果進入Trigger物件無ObstaclePropertyinfo ,則離開此函式
        if (infoScript == null)
            return;

        //確認角色本身是否對應正確的障礙物
        if (this.ObstacleList.Contains(infoScript.Obstacle))
        {
            infoScript.CheckObstacle(true);
        }
        else
        {
            //創建 撞擊特效BoneAnimation
            SmoothMoves.BoneAnimation obj = (SmoothMoves.BoneAnimation)Instantiate(GameManager.script.EffectAnimationObject);
            obj.mLocalTransform.position = other.ClosestPointOnBounds(this.transform.position) - Vector3.forward;
            obj.playAutomatically = false;
            //隨機撥放 1 或 2 動畫片段
            if (Random.Range(0, 2) == 0)
                obj.Play("撞擊特效01");
            else
                obj.Play("撞擊特效02");

            infoScript.CheckObstacle(false);
            //給予角色傷害
            this.roleInfo.DecreaseLife(infoScript.Damage);
        }
    }
开发者ID:joeytsao,项目名称:Game_JIC,代码行数:30,代码来源:ObstacleSystem.cs

示例7: OnTriggerEnter

    void OnTriggerEnter(Collider other)
    {
        // 怪物必須未死亡
        if (!this.enemyInfo.isDead)
        {
            //撞擊角色並造成角色傷害
            if (((1 << other.gameObject.layer) & this.AttackLayer.value) > 0)
            {
                //tag = MainBody
                if (other.collider.tag.CompareTo("MainBody") == 0)
                {
                    //創建 撞擊特效BoneAnimation
                    SmoothMoves.BoneAnimation obj = (SmoothMoves.BoneAnimation)Instantiate(GameManager.script.EffectAnimationObject);
                    obj.mLocalTransform.position = other.ClosestPointOnBounds(this.transform.position) - Vector3.forward;
                    obj.playAutomatically = false;
                    //隨機撥放 1 或 2 動畫片段
                    if (Random.Range(0, 2) == 0)
                        obj.Play("撞擊特效01");
                    else
                        obj.Play("撞擊特效02");

                    //給予角色傷害
                    other.GetComponent<RolePropertyInfo>().DecreaseLife(enemyInfo.damage);
                }
            }
        }
    }
开发者ID:joeytsao,项目名称:Game_JIC,代码行数:27,代码来源:EnemyAttackController_TreeMan.cs

示例8: OnTriggerEnter

    void OnTriggerEnter(Collider c)
    {
        int			i;
        GameObject	tmp;

        if (c.gameObject.tag == "enemy" && player != null && player.attacking)
        {
            enemy en = c.gameObject.GetComponentInParent<enemy>();
            if (en != null && !en.dead)
            {
                stats e = en.st;
                if (e != null)
                {
                    if (player.st.hitChance(e))
                    {
                        i = Random.Range(0, player.bloodEffects.Length);
                        tmp = (GameObject)Instantiate(player.bloodEffects[i], c.ClosestPointOnBounds(player.inv.equipedItems[0].transform.position), Quaternion.identity);
                        tmp.SetActive(true);
                        player.slashSounds[Random.Range(0, player.slashSounds.Length)].Play();
                        int dmg = player.st.finalDamage(e) + ist.finalDamage(e);
                        e.hp -= dmg;
                        if (e.hp <= 0)
                            e.hp = 0;
                        tmp = (GameObject)Instantiate(player.textPop, c.ClosestPointOnBounds(player.inv.equipedItems[0].transform.position), Quaternion.identity);
                        tmp.SetActive(true);
                        tmp.transform.LookAt(player.cam.transform.position);
                        tmp.transform.eulerAngles = new Vector3(tmp.transform.eulerAngles.x, tmp.transform.eulerAngles.y + 180, tmp.transform.eulerAngles.z);
                        textPop tp = tmp.GetComponent<textPop>();
                        tp.addConfig(dmg.ToString());
                        tp.addConfig(new Color(1.0f, 1.0f, 1.0f, 1.0f), 0.25f, 20.0f);
                        tp.addConfig(new Vector3(0.0f, 1.0f, 0.0f), 2.0f);
                    }
                    else
                    {
                        tmp = (GameObject)Instantiate(player.textPop, c.ClosestPointOnBounds(player.inv.equipedItems[0].transform.position), Quaternion.identity);
                        tmp.SetActive(true);
                        tmp.transform.LookAt(player.cam.transform.position);
                        tmp.transform.eulerAngles = new Vector3(tmp.transform.eulerAngles.x, tmp.transform.eulerAngles.y + 180, tmp.transform.eulerAngles.z);
                        textPop tp = tmp.GetComponent<textPop>();
                        tp.addConfig("miss");
                        tp.addConfig(new Color(1.0f, 1.0f, 1.0f, 1.0f), 0.25f, 20.0f);
                        tp.addConfig(new Vector3(0.0f, 1.0f, 0.0f), 2.0f);
                    }
                }
            }
        }
    }
开发者ID:rdavid42,项目名称:hack-n-Slash,代码行数:47,代码来源:meleeAttack.cs

示例9: OnTriggerStay

 void OnTriggerStay(Collider coll)
 {
     if(coll.gameObject.tag == "Player")
     {
         dir = coll.ClosestPointOnBounds(coll.gameObject.transform.position);
         rb.AddForceAtPosition(Vector3.down * power * Time.deltaTime, dir);
     }
 }
开发者ID:FinishProject,项目名称:Secreto,代码行数:8,代码来源:Balance.cs

示例10: OnTriggerEnter

 // Use this for trigger event
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject == player)
     {
         playerInRange = true;
         collisionPoint = other.ClosestPointOnBounds(transform.position);
     }
 }
开发者ID:LLucile,项目名称:NuitBlanche,代码行数:9,代码来源:EnemyAttack.cs

示例11: OnTriggerStay

 /// <summary>
 /// If the portal is inside the ground, it will be pushed out.
 /// </summary>
 void OnTriggerStay(Collider collider)
 {
     if (collider.tag == "Ground")
     {
         Vector3 distanceNormal = transform.position - collider.ClosestPointOnBounds(transform.position);
         distanceNormal.Normalize();
         transform.position += distanceNormal * 0.02f;
     }
 }
开发者ID:SPCoffey,项目名称:UnityPortalScript,代码行数:12,代码来源:Waver.cs

示例12: OnTriggerEnter

 void OnTriggerEnter(Collider collider)
 {
     if(collider.gameObject.layer == LayerMask.NameToLayer("Player")){
         parentAttack.enemyCollisionEnter (collider.gameObject,collider.ClosestPointOnBounds(transform.position));
         Destroy(gameObject);
     }else if(collider.gameObject.layer == LayerMask.NameToLayer("Planets")){
         Destroy(gameObject);
     }
 }
开发者ID:JosepFloriach,项目名称:LightguardLegacy,代码行数:9,代码来源:Banana.cs

示例13: OnTriggerEnter

 void OnTriggerEnter(Collider hit)
 {
     if(hit.gameObject.tag == "Player")
     {
         Vector3 direction = hit.ClosestPointOnBounds(this.transform.position);
         hit.gameObject.GetComponent<Character>().knockBack(direction);
         hit.gameObject.GetComponent<Character>().takeDamage(10,this.gameObject);
     }
 }
开发者ID:WindchillStudios,项目名称:project-fightclub,代码行数:9,代码来源:ExplosionScript.cs

示例14: OnTriggerEnter

	void OnTriggerEnter(Collider coll)
	{
		print (1);
		if (coll.gameObject.tag == "Player") {
			print (2);
			GameObject bump = Instantiate (bumpEmitter) as GameObject;
			bump.transform.position = coll.ClosestPointOnBounds(transform.position);
			bump.audio.Play();
			Destroy (bump,5);
		}
	}
开发者ID:CarlosMeloStuff,项目名称:EchoLocation,代码行数:11,代码来源:WallHit.cs

示例15: OnTriggerEnter

  void OnTriggerEnter(Collider other) {
    if(PropulsionPadActive()) {
      //////////////////////////////////////////////////////////////////
      // To prevent the collider from missing the target, get the
      // closest point the collider hit on the trigger and calculate the
      // velocity based on that starting point.
      Vector3 hitPoint = other.ClosestPointOnBounds(transform.position);
      PropelObject(other.gameObject, CalculateVelocity(hitPoint));
		
    }
  }
开发者ID:Bakiet,项目名称:UnityZombieCross,代码行数:11,代码来源:tsg_PropulsionPhysics.cs


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