Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class SCR_RayCast : MonoBehaviour
- {
- public float CastDistance;
- RaycastHit WhatIHit;
- public PlayerController Player;
- public SCR_Enemy Enemy;
- // Use this for initialization
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- if (Input.GetMouseButtonDown(0))
- {
- if (Player.CrossbowEquip == true)
- {
- Debug.DrawRay(this.transform.position, this.transform.forward * CastDistance, Color.magenta);
- if (Physics.Raycast(this.transform.position, this.transform.forward, out WhatIHit, CastDistance))
- {
- //Debug.Log("I am hitting the " +WhatIHit.collider.gameObject.name);
- if (WhatIHit.collider.tag == "Enemy")
- {
- Enemy.e_health -= 50;
- //Destroy(WhatIHit.collider.gameObject);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement