Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class SCR_RayCast : MonoBehaviour
  6. {
  7. public float CastDistance;
  8.  
  9. RaycastHit WhatIHit;
  10.  
  11. public PlayerController Player;
  12. public SCR_Enemy Enemy;
  13.  
  14. // Use this for initialization
  15. void Start()
  16. {
  17.  
  18. }
  19.  
  20. // Update is called once per frame
  21. void Update()
  22. {
  23. if (Input.GetMouseButtonDown(0))
  24. {
  25. if (Player.CrossbowEquip == true)
  26. {
  27.  
  28. Debug.DrawRay(this.transform.position, this.transform.forward * CastDistance, Color.magenta);
  29. if (Physics.Raycast(this.transform.position, this.transform.forward, out WhatIHit, CastDistance))
  30. {
  31. //Debug.Log("I am hitting the " +WhatIHit.collider.gameObject.name);
  32. if (WhatIHit.collider.tag == "Enemy")
  33. {
  34. Enemy.e_health -= 50;
  35. //Destroy(WhatIHit.collider.gameObject);
  36. }
  37. }
  38. }
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement