Last active
December 18, 2017 11:22
-
-
Save tarukosu/4294fbf2bce9da19941d8689c2661e5a to your computer and use it in GitHub Desktop.
GunScript.cs
This file contains 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 UnityEngine; | |
public class GunScript : MonoBehaviour { | |
public ITangoController TangoController; | |
public GameObject LaserBeam; | |
bool previousSelectButton = false; | |
private GameObject muzzle; | |
... | |
void Start () { | |
muzzle = transform.Find("Muzzle").gameObject; | |
muzzle.transform.localPosition = new Vector3(0f, -0.1f, 0.2f); | |
muzzle.transform.localRotation = Quaternion.Euler(5f, 0f, 0f); | |
... | |
} | |
... | |
void Update () { | |
if(TangoController == null) | |
{ | |
return; | |
} | |
var t = 0.8f; | |
transform.localPosition = Vector3.Lerp(transform.localPosition, TangoController.transform.position, t); | |
transform.localRotation = Quaternion.Lerp(transform.localRotation, TangoController.transform.rotation, t); | |
// ビームの発射 | |
if (previousSelectButton == false && TangoController.SelectButton) | |
{ | |
var beam = Instantiate(LaserBeam, muzzle.transform.position, muzzle.transform.rotation); | |
} | |
previousSelectButton = TangoController.SelectButton; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment