本文整理汇总了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;
}
}
示例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;
}
}
示例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));
}
}
示例4: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.tag == "Enemy") {
IAController enemy = other.GetComponent<IAController>();
enemy.getHurt(damage,other.ClosestPointOnBounds(transform.position),true);
}
}
示例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();
}
}
}
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
}
}
}
}
示例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);
}
}
示例10: OnTriggerEnter
// Use this for trigger event
void OnTriggerEnter(Collider other)
{
if (other.gameObject == player)
{
playerInRange = true;
collisionPoint = other.ClosestPointOnBounds(transform.position);
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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));
}
}