Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- using Devdog.General2;
- namespace Grendelbiter
- {
- public class SetTarget : MonoBehaviour, IPlayerInputCallbacks
- {
- [SerializeField] private GameObject Target;
- private void Update()
- {
- if (Input.GetButton("Fire1"))
- {
- TargetSet();
- }
- }
- public virtual void SetInputActive(bool val)
- {
- enabled = val;
- }
- private void TargetSet()
- {
- if (!EventSystem.current.IsPointerOverGameObject() && enabled)
- {
- RaycastHit hit;
- Ray ray;
- ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- int layerMask = 1 << 8;
- if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
- {
- Target.transform.position = hit.point;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement