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
RaycastHit hit; | |
void Update() | |
{ | |
Ray ray = new Ray(transform.position, transform.TransformDirection(Vector3.up)); | |
// レイ飛ばす | |
if (Physics.SphereCast(ray, 1f, out hit, 100f)) | |
{ | |
Debug.Log(hit.collider.gameObject.name); |
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
RaycastHit hit; | |
void Update() | |
{ | |
// レイ飛ばす | |
if (Physics.BoxCast(transform.position, Vector3.one * 0.5f, transform.TransformDirection(Vector3.up), out hit)) | |
{ | |
Debug.Log(hit.collider.gameObject.name); | |
} | |
} |
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
void Update() | |
{ | |
// クリックした位置へのレイ取得 | |
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); | |
RaycastHit hit; | |
// クリックしたら | |
if (Input.GetMouseButtonDown(0)) | |
{ | |
// レイ飛ばす |
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 UnityEngine; | |
public class VectorScript : MonoBehaviour | |
{ | |
void Start() | |
{ | |
Vector3 vec = new Vector3(1, -5, 0); | |
//(1, 5, 0)になる | |
Vector3 res = Vector3.Reflect(vec, Vector3.up); |
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 UnityEngine; | |
public class VectorScript : MonoBehaviour | |
{ | |
void Update() | |
{ | |
Vector3 from = Vector3.right * -5f; //現在地 | |
Vector3 to = transform.position; //目的地 | |
float smoothTime = Time.deltaTime * 0.1f; //移動スピード |
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 UnityEngine; | |
public class VectorScript : MonoBehaviour | |
{ | |
void Update() | |
{ | |
Vector3 current = Vector3.right * -5; //現在地 | |
Vector3 target = Vector3.right * 5; //目標値 | |
float maxRadiansDelta = Time.time; //2点間におけるラジアンの差分の範囲内で設定する |
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 UnityEngine; | |
public class VectorScript : MonoBehaviour | |
{ | |
void Update() | |
{ | |
Vector3 current = Vector3.zero; //現在地 | |
Vector3 target = Vector3.one*10; //目標値 | |
float maxDist = Time.time; //進む距離 |
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 UnityEngine; | |
public class VectorScript : MonoBehaviour | |
{ | |
void Update() | |
{ | |
Vector3 from = Vector3.zero; | |
Vector3 to = Vector3.one*10; | |
transform.position = Vector3.Slerp(from, to, Time.time * 0.3f); |
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 UnityEngine; | |
public class VectorScript : MonoBehaviour | |
{ | |
void Update() | |
{ | |
Vector3 from = Vector3.zero; | |
Vector3 to = Vector3.one*10; | |
transform.position = Vector3.Lerp(from, to, Time.time * 0.3f); |
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 UnityEngine; | |
public class VectorScript : MonoBehaviour | |
{ | |
void Start() | |
{ | |
Vector3 vec = new Vector3(100f, 10f, 30f); | |
//1.0, 0.1, 0.3 になる。 | |
Vector3 nmz = vec.normalized; |
NewerOlder