Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma strict
- var Damage : int = 5;
- var Distance : float;
- var MaxDistance : float = 1.5;
- var Knife : Transform;
- function Update ()
- {
- if (Input.GetMouseButtonDown(0)){
- Knife.GetComponent.<Animation>().Play("Knife_Swing");
- var hit : RaycastHit;
- if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit)) {
- Distance = hit.distance;
- if (Distance < MaxDistance) {
- hit.transform.SendMessage(("ApplyDamage"), Damage, SendMessageOptions.DontRequireReceiver);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement