제목 그대로 움직이지 않아요
{
public float maxSpeed;
Rigidbody2D rigid;
void Awake()
{
rigid = GetComponent<Rigidbody2D>();
}
void FixedUpdate()
{
//Horizontal Movement
float h = Input.GetAxisRaw("Horizontal");
rigid.AddForce(Vector2.right * h, ForceMode2D.Impulse);
//Speed Limit
if (rigid.velocity.x > maxSpeed) //R
rigid.velocity = new Vector2(maxSpeed, rigid.velocity.y);
else if (rigid.velocity.x < maxSpeed * (-1)) //L
rigid.velocity = new Vector2(maxSpeed * (-1), rigid.velocity.y);
}
}
코드는 이렇게 짰습니다
아래 스피드 리밋 쪽 빼면 잘 작동 하는 걸 보니 거기가 문제인 것 같은데 도와주세요
골드 메탈 강의 보는 중이군요 도움이 될까 싶은데 저의 경우 else if (rigid.velocity.x < -maxSpeed ) //L 로 바꾸었더니 동작 되더군요 그리고 문장 한줄이라도 { } 넣어주는게 좋습니다. 쓰다보면 햇갈립니다.
해당하는 명령어로 바꿔도 해결되진 않네요....그래도 조언해주셔서 감사합니다
maxSpeed 에 값 대입은 했음? - dc App
헐 그렇네요;; 급하게 배우려고 해서 그런지 대입 하는 걸 까먹어버렸네요.... 너무 감사합니다