Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using MoreMountains.Tools;
- public class MousePosition3D : MonoBehaviour
- {
- [SerializeField] private Camera mainCamera;
- [SerializeField] private LayerMask WhatIsGround;
- [SerializeField] private float Range;
- [SerializeField]private GameObject playerObj;
- private WebMovement webMovement;
- // Start is called on the frame when a script is enabled just before any of the Update methods is called the first time.
- private void Start()
- {
- webMovement = GetComponent<WebMovement>();
- Invoke("GetGameObjectWithMethod",2f);
- }
- private void Update()
- {
- Ray ray = mainCamera.ScreenPointToRay(new Vector3(Input.mousePosition.x,Input.mousePosition.y,0f));
- if(Physics.Raycast(ray, out RaycastHit raycastHit,WhatIsGround))
- {
- transform.position = raycastHit.point;
- }
- }
- public void GetGameObjectWithMethod()
- {
- playerObj = GameObject.FindGameObjectWithTag("Player");
- webMovement.playerObj = playerObj;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement