내 플레이어가 계속해서 화면 아래쪽으로 떨어지는 경우 플레이어가 다른 게임 개체와 상호 작용할 때 해당 게임 개체를 파괴하고 플레이어가 계속 떨어지고 싶습니다.gameObject와 접촉하면 플레이어가 움직이지 않습니다.
하지만 플레이어가 다른 게임 개체를 친 순간에 게임 개체는 파괴되지만 플레이어는 떨어지는 것을 멈 춥니 다. 내가 뭘 잘못하고 있는지 조언 해주세요.
//Script attached to player:
//x-axis movement speed
public float playerMoveSpeed = 0.2f;
//how much force to act against the gravity
public float upForce = 9.0f;
//horizontal control
private float move;
// Update is called once per frame
void Update()
{
//player left right x-axis movement control
move = Input.GetAxis("Horizontal") * playerMoveSpeed;
transform.Translate(move, 0, 0);
}
void FixedUpdate()
{
//to fight against the gravity pull, slow it down
rigidbody.AddForce(Vector3.up * upForce);
}
//Script attached to gameObject to be destroyed on contact with player
void OnCollisionEnter(Collision col)
{
//as long as collide with player, kill object
if (col.gameObject.tag == "Player")
{
Destroy(gameObject);
}
}