Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class RayCast : MonoBehaviour
- {
- public float Range = 2;
- void Update()
- {
- Atack();
- }
- void Atack()
- {
- Vector3 DirectionRay = transform.TransformDirection(Vector3.forward);
- RaycastHit Hit;
- if (Physics.Raycast(transform.position, DirectionRay, out Hit, Range))
- {
- //Debug.DrawLine(transform.position, Hit.point, Color.green);
- if (Hit.collider.tag == "Interaction")
- {
- if (Input.GetKeyDown(KeyCode.E))
- {
- if (Hit.collider.GetComponent<InteractionController>().InteractionTrue == false)
- {
- Hit.collider.GetComponent<InteractionController>().InteractionTrue = true;
- }
- else
- {
- Hit.collider.GetComponent<InteractionController>().InteractionTrue = false;
- }
- }
- Hit.collider.GetComponent<InteractionController>().Icon = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement