Skip to content

Instantly share code, notes, and snippets.

@EdSkamor
Created September 15, 2017 10:02
Show Gist options
  • Select an option

  • Save EdSkamor/97da91e81333935433c5d979334bd451 to your computer and use it in GitHub Desktop.

Select an option

Save EdSkamor/97da91e81333935433c5d979334bd451 to your computer and use it in GitHub Desktop.
ShotGunCamera
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