세이브 포인트 생성하기
![savepoint_result](/images/snippet/redbrick-extension/savepoint_result.gif)
코드
🚫
onCollide
같은 메소드를 사용하려면 객체의 속성 패널에서 Body를 체크하는 것을
잊지 마세요!
![snippet_physics-body](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fsnippet_physics-body.a07c5968.png&w=1920&q=75)
let startLocation = WORLD.getObject("StartLocation(aa3)");
function Start() {
// 4 save points form spawn1 ~ spawn4
for (let i = 1; i < 5; i++) {
const point = WORLD.getObject("spawn" + i);
point.onCollide(PLAYER, () => {
startLocation = point;
});
}
}
function Update(dt) {
//respawn when avatar y position is less than -5
if (PLAYER.position.y < -5) {
PLAYER.spawn(startLocation);
}
}