P
P
Pavel Arutyunov2022-01-29 15:38:17
Mobile development
Pavel Arutyunov, 2022-01-29 15:38:17

How to make Checkpoint in Unity?

Hello!
I want to implement the Checkpoint system in a Unity2D project. It is necessary that when the Player enters the Checkpoint's coverage area, the player's position is saved and when the scene is reloaded, the player appears at the position that the Checkpoint saved. There are guides on this topic on YouTube, but not one of them works in my project.
PS Does the save system depend on the player's script or not?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Farawa, 2022-01-29
@GLaWA_RaKoB

You make an empty object with a trigger collider, throw a script on it, in which ontriggerenter2d checks whether it is a player and already through other.getcomponen().SetCheckpoint(transform.position) you set the player’s position

A
artem_kotov_7, 2022-02-02
@artem_kotov_7

to save position use https://docs.unity3d.com/ScriptReference/PlayerPre...
transform.position convert to json string and save it PlayerPrefs.SetString

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question