Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.39 KB | None | 0 0
  1. public class BarrelMovement : MonoBehaviour
  2. {
  3.     // Update is called once per frame
  4.     void Update()
  5.     {
  6.         Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
  7.         mousePosition = new Vector3(mousePosition.x, mousePosition.y, 0);
  8.  
  9.         Vector3 barrelPosition = transform.position;
  10.  
  11.         transform.up = mousePosition - barrelPosition;
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement