Advertisement
Guest User

rotate

a guest
Oct 20th, 2022
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class rotate : MonoBehaviour
  6. {
  7. // Start is called before the first frame update
  8. [SerializeField]
  9. private GameObject player;
  10. [SerializeField]
  11. private Collider floorCollider;
  12. void FixedUpdate()
  13. {
  14.  
  15. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  16. RaycastHit hitInfo;
  17. if (floorCollider.Raycast(ray, out hitInfo, Mathf.Infinity)){
  18. hitInfo.point = new Vector3(hitInfo.point.x, player.transform.position.y, hitInfo.point.z);
  19. transform.LookAt(hitInfo.point);
  20. }
  21. else { Debug.Log("Nie widzisz podlogi"); }
  22. }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement