照準器で狙った位置にロケット弾を発射する
ロケット弾を切り替える
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraMoveController : MonoBehaviour {
public GameObject player;
public float rotateSpeed;
private const float angleLimitUp = 30f;
private const float angleLimitDown = -60f;
public Camera mainCamera;
public Camera subCamera;
private Vector3 angle;
public GameObject aimObject;
public GameObject rifle;
public GameObject shotBullet2;
// ★追加
public GameObject shotRocket2;
public GameObject rocketLauncher;
void Start(){
mainCamera.enabled = true;
subCamera.enabled = false;
}
void Update () {
transform.position = player.transform.position;
angle = player.transform.eulerAngles;
transform.eulerAngles = new Vector3 (transform.eulerAngles.x, angle.y, transform.eulerAngles.z);
if (Input.GetMouseButton (0)) {
RotateCameraAngle ();
mainCamera.enabled = false;
subCamera.enabled = true;
aimObject.SetActive(true);
rifle.SetActive (false);
shotBullet2.SetActive(true);
// ★追加
shotRocket2.SetActive(true);
rocketLauncher.SetActive (false);
} else {
mainCamera.enabled = true;
subCamera.enabled = false;
aimObject.SetActive(false);
rifle.SetActive (true);
// ★追加
shotRocket2.SetActive(false);
rocketLauncher.SetActive (true);
}
float angle_x = 180f <= transform.eulerAngles.x ? transform.eulerAngles.x - 360f : transform.eulerAngles.x;
transform.eulerAngles = new Vector3(Mathf.Clamp(angle_x, angleLimitDown, angleLimitUp), transform.eulerAngles.y, transform.eulerAngles.z);
}
void RotateCameraAngle(){
Vector3 angle = new Vector3(Input.GetAxis("Mouse X") * rotateSpeed, -Input.GetAxis("Mouse Y") *rotateSpeed, 0);
transform.eulerAngles += new Vector3(angle.y, angle.x, 0);
}
}
EscapeCombat(メモ)
他のコースを見るロケット弾を切り替える
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraMoveController : MonoBehaviour {
public GameObject player;
public float rotateSpeed;
private const float angleLimitUp = 30f;
private const float angleLimitDown = -60f;
public Camera mainCamera;
public Camera subCamera;
private Vector3 angle;
public GameObject aimObject;
public GameObject rifle;
public GameObject shotBullet2;
// ★追加
public GameObject shotRocket2;
public GameObject rocketLauncher;
void Start(){
mainCamera.enabled = true;
subCamera.enabled = false;
}
void Update () {
transform.position = player.transform.position;
angle = player.transform.eulerAngles;
transform.eulerAngles = new Vector3 (transform.eulerAngles.x, angle.y, transform.eulerAngles.z);
if (Input.GetMouseButton (0)) {
RotateCameraAngle ();
mainCamera.enabled = false;
subCamera.enabled = true;
aimObject.SetActive(true);
rifle.SetActive (false);
shotBullet2.SetActive(true);
// ★追加
shotRocket2.SetActive(true);
rocketLauncher.SetActive (false);
} else {
mainCamera.enabled = true;
subCamera.enabled = false;
aimObject.SetActive(false);
rifle.SetActive (true);
// ★追加
shotRocket2.SetActive(false);
rocketLauncher.SetActive (true);
}
float angle_x = 180f <= transform.eulerAngles.x ? transform.eulerAngles.x - 360f : transform.eulerAngles.x;
transform.eulerAngles = new Vector3(Mathf.Clamp(angle_x, angleLimitDown, angleLimitUp), transform.eulerAngles.y, transform.eulerAngles.z);
}
void RotateCameraAngle(){
Vector3 angle = new Vector3(Input.GetAxis("Mouse X") * rotateSpeed, -Input.GetAxis("Mouse Y") *rotateSpeed, 0);
transform.eulerAngles += new Vector3(angle.y, angle.x, 0);
}
}
照準器で狙った位置にロケット弾を発射する