Created
September 15, 2017 10:02
-
-
Save EdSkamor/97da91e81333935433c5d979334bd451 to your computer and use it in GitHub Desktop.
ShotGunCamera
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| using UnityStandardAssets.CrossPlatformInput; | |
| // ShotGunCamera | |
| public class CameraScipt : MonoBehaviour { | |
| // Add cube : (-1, 1, -5), (1, 1.5, -5), (-1, -2, 5) i (1.5, 0, 0). | |
| void Update () { | |
| float dirX = CrossPlatformInputManager.GetAxis("Mouse X"); | |
| float dirY = CrossPlatformInputManager.GetAxis("Mouse Y"); | |
| transform.Rotate(dirY, dirX, 0); | |
| CheckForRaycastHit(); | |
| } | |
| void CheckForRaycastHit() | |
| { | |
| RaycastHit hit; | |
| if (Physics.Raycast(transform.position, transform.forward, out hit)) | |
| { | |
| print(hit.collider.gameObject.name + " destroy!"); | |
| Destroy(hit.collider.gameObject); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment