using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TappingBAll : MonoBehaviour
{
public Vector3 moveVelocity;
public float movePower = 6;
float moveVelocityx = 1;
float moveVelocityy = 1;
void Movedd()// 플레이어가 왼쪽으로 이동하는 함수.
{
moveVelocity = new Vector3(moveVelocityx, moveVelocityy, 0);
transform.position += moveVelocity * movePower * Time.deltaTime;
Debug.Log(transform.position);
}
void Update()
{
Movedd();// 플레이어가 왼쪽으로 이동하는 함수.
if (Input.GetKeyDown(KeyCode.UpArrow))
{
Turn();
}
}
float Turn()
{
//Vector3 moveVelocity = Vector3.zero;
this.moveVelocityx = Random.Range(-1.0f, 1.0f);
this.moveVelocityy = Random.Range(-1.0f, 1.0f);
return moveVelocityx;
return moveVelocityy;
}
}
주석은 무시해주셈 잘못친거임
방향 벡터는 항상 일정한 길이를 가져야 하므로 정규화를 해줘야함 normalized 대충 이런 이름의 변수가 moveVelocity에 있을 것임
moveVelocity.normalized