本文整理汇总了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;
}
示例2: OnControllerColliderHit
/*////////////////////////////////////*/
//Fonction des Dommages
/*////////////////////////////////////*/
void OnControllerColliderHit(ControllerColliderHit collision)
{
if(collision.gameObject.tag == "Player")
{
animator.SetBool("Hit", true);
}
}
示例3: OnControllerColliderHit
void OnControllerColliderHit(ControllerColliderHit coll)
{
if(coll.gameObject.tag == damageTag)
{
myKillable.Damage(damageRate);
}
}
示例4: OnControllerColliderHit
void OnControllerColliderHit(ControllerColliderHit other)
{
if (other.gameObject.GetComponent<DeathOnContact>() != null)
{
Kill();
}
}
示例5: OnControllerColliderHit
public void OnControllerColliderHit(ControllerColliderHit hit)
{
}
示例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;
}
示例7: OnControllerColliderHit
void OnControllerColliderHit(ControllerColliderHit hit)
{
if(hit.gameObject.tag == "boulder")
{
hit.rigidbody.AddForce(transform.forward * speed);
}
}
示例8: OnControllerColliderHit
void OnControllerColliderHit(ControllerColliderHit hit)
{
if(hit.transform.tag == "Building")
{
GameOver();
}
}
示例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;
}
}
示例10: CollisionNodeInfo
public CollisionNodeInfo(CollisionNodeToggler hitNode, Collider colliderObj, Collision collisionObj, ControllerColliderHit cchit)
{
this.hitNode = hitNode;
collider = colliderObj;
collision = collisionObj;
controllerColliderHit = cchit;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
示例15: OnControllerColliderHit
//OnControllerColliderHit(ControllerColliderHit hit)
void OnControllerColliderHit(ControllerColliderHit hit)
{
if (hit.transform.tag == "shark"){
Destroy(gameObject);
Application.LoadLevel(Application.loadedLevel);
}
}