noocrypte.net http://noozone.free.fr/noocrypte/ |
|
Unity-Script-Push any object http://noozone.free.fr/noocrypte/viewtopic.php?f=47&t=865 |
Page 1 sur 1 |
Auteur: | yann.minh [ Jeu Mar 10, 2011 5:48 pm ] |
Sujet du message: | Unity-Script-Push any object |
Push Any Object Code: //ENG: this script pushes all rigidbodies that the character touches
//ESP: este script empuja todos los rigidbodies que el personaje toca var pushPower = 2.0; function OnControllerColliderHit (hit : ControllerColliderHit) { var body : Rigidbody = hit.collider.attachedRigidbody; //ENG: no rigidbody //ESP: no hay rigidbody if (body == null || body.isKinematic) return; //ENG: We dont want to push objects below us //ESP: no queremos empujar objetos que esten detras nuestro if (hit.moveDirection.y < -0.3) return; //ENG: Calculate push direction from move direction, we only push objects to the sides never up and down //ESP: calcular la direccion del empujon desde la direccion de movimiento var pushDir = Vector3 (hit.moveDirection.x, 0, hit.moveDirection.z); //ENG: If you know how fast your character is trying to move, then you can also multiply the push velocity by that. //ESP: si quieres saber como de rapido esta intentando tu personaje moverse, entonces puedes tambien multiplicar la velocidad de empujón por ello //ENG: Apply the push //ESP: Aplica el empujón body.velocity = pushDir * pushPower; } |
Page 1 sur 1 | Heures au format UTC [ Heure d’été ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |