void Move()
{
Vector3 dir = target.transform.position - gameObject.transform.position ;
dir.Normalize();
//transform.position += dir * speed * Time.deltaTime
//cc.Move(dir * speed * Time.deltaTime);
cc.SimpleMove(dir * speed); //์ ํ ๋ชปํจ
//target์ ๋ฐ๋ผ๋ณด๊ฒ ํ๊ณ ์ถ๋ค
//1. transform.LookAt(target.transform);
//2. transform.forward = dir;
//+ ๋ถ๋๋ฝ๊ฒ ํ์ ํ๊ณ ์ถ๋ค
transform.forward = Vector3.Lerp(transform.forward, dir, rotSpeed * Time.deltaTime);
}
Vertext : ์ , Edge : ์ , Polygon : ๋ฉด, Mesh : ๋ฉด์ ๋ชจ์
Material
-> texture
-> shader: mesh๋ฅผ ์ด๋ค ๋๋์ผ๋ก ๊ทธ๋ฆด์ง ์ ์ํ ๊ฒ
public class PlayerMove : MonoBehaviour
{
public float speed = 6.0F;
public float jumpSpeed = 8.0F;
public float gravity = 20.0F;
private Vector3 moveDirection = Vector3.zero;
void Update()
{
CharacterController controller = GetComponent<CharacterController>();
if (controller.isGrounded)
{
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
speed = 6.0F;
if (Input.GetKey(KeyCode.LeftShift)) //๋ฌ๋ฆฌ๊ธฐ ๊ตฌํ
{
speed = 12.0F;
}
moveDirection *= speed;
if (Input.GetButton("Jump"))
moveDirection.y = jumpSpeed;
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
}
public class PlayerRot_00 : MonoBehaviour
{
//๋ง์ฐ์ค์ ํ์ ๋์ ์น๋ฅผ ์ ์ฅํ ๋ณ์
float mx;
float my;
//ํ์ ํ ์๋
float rotSpeed = 500;
//ํ์ ๊ฐ๋ฅ ์ฌ๋ถ
public bool canRotH;
public bool canRotV;
// ์ง๋ ํฌ๊ธฐ
public float amp = 0.07f;
public float freq = 20;
float tempY;
private void Start()
{
tempY = transform.localPosition.y;
mx = transform.localEulerAngles.x;
my = transform.localEulerAngles.y;
}
void Update()
{
//๋ง์ฐ์ค์ ์์ง์์ ๋ฐ์์
float h = Input.GetAxis("Mouse X");
float v = Input.GetAxis("Mouse Y");
//๋ง์ฐ์ค์ ํ์ ๊ฐ์ผ๋ก ๊ฐ๋๋ฅผ ๋์ ํ๊ณ (๊ณ์ฐํ๊ณ )
if (canRotV)
mx += v * rotSpeed * Time.deltaTime;
if (canRotH)
my += h * rotSpeed * Time.deltaTime;
//mx ์ต์๊ฐ์ -60, ์ต๋๊ฐ์ 60์ผ๋ก ์
ํ
mx = Mathf.Clamp(mx, -60, 60);
//๋์ ๋ ํ์ ๊ฐ์ผ๋ก ๊ฒ์์ค๋ธ์ ํธ์ ๊ฐ๋๋ฅผ ์
ํ
ํ์
transform.localEulerAngles = new Vector3(-mx, my, 0);
// ๋ง์ฝ ์นด๋ฉ๋ผ๋ผ๋ฉด
if (gameObject.tag == "MainCamera")
{
if (Input.GetButton("Horizontal") || Input.GetButton("Vertical"))
{
amp = 0.07f;
freq = 20;
if (Input.GetKey(KeyCode.LeftShift)) //๋ฌ๋ฆฌ๊ธฐ ๊ตฌํ
{
print("shift๋๋ฆผ");
amp = 0.07f;
freq = 50;
}
transform.localPosition = new Vector3(0, tempY + amp * Mathf.Sin(freq * Time.time), 0);
}
}
}
}