Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Alphacreations · Jul 17, 2020 at 06:12 AM · enemycheckpoint

how do I make smart checkpoints?

I have made checkpoints in unity and they work ok (they respawn the character when the character dies) but all the enemies that my character has killed so far has respawned with the character. How do I make the checkpoint know not to spawn enemies after they die?

here is my playerpos script (which makes the player move to the last checkpoint position)

  public class PlayerPos : MonoBehaviour
 {
     private GameMaster GM;
 
      void Start()
     {
         GM = GameObject.FindGameObjectWithTag("GM").GetComponent<GameMaster>();
         transform.position = GM.lastCheckpointPos;
     }
 
 }

here is my checkpoint script:

 public class CheckPoint : MonoBehaviour
 {
     private GameMaster GM;
 
     private void Start()
     {
         GM = GameObject.FindGameObjectWithTag("GM").GetComponent<GameMaster>();
     }



     
     private void OnTriggerEnter2D(Collider2D other)
     {
         if (other.CompareTag("Player"))
         {
             GM.lastCheckpointPos = transform.position;
         }
     }
 }

here is my Gamemaster script:

 public class GameMaster : MonoBehaviour
 {
     // Start is called before the first frame update
     private static GameMaster instance;
     public Vector2 lastCheckpointPos;
      void Awake()
     {
         if(instance == null)
         {
             instance = this;
             DontDestroyOnLoad(instance);
         }
         else
         {
             Destroy(gameObject);
         }
 
         
     }
 }
 

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Acdia · Jul 17, 2020 at 06:33 AM 0
Share

How do you respawn the player? Do you reload the scene? If so, I think it would be better to just reset the stats oft the player. Otherwise I'm not sure why the enemies geht respawned too. Could you descripe it further?

avatar image Alphacreations Acdia · Jul 17, 2020 at 06:50 AM 0
Share

I respawn the player by reloading the scene. I have updated my post to put my checkpoint script

avatar image xxmariofer Alphacreations · Jul 17, 2020 at 07:34 AM 0
Share

dont respawn the player reloading the scene simply move it to the desire position

avatar image Acdia · Jul 17, 2020 at 07:24 AM 0
Share

Ok, thx. So as already said I would just reset the stats of the player and put him back to the last checkpoint or destroy the player and load it from a prefab again(make sure to do that in the same frame). Reloading the scene is also more intense for the computer. In my opinion the only reason to reload the scene, while not resetting the whole level (respawn enemies as well), would be if you have another scene you use before respawning the player. In that case I can't help you a lot since I have never die this before and currently can't test with Unity.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Alphacreations · Jul 19, 2020 at 10:24 PM

i made a new vector 3 and had 1 variable ; respawnpoint

i made it if the player collides with the checkpoint, the respawnpoint is equal the the transform.position of the checkpoint

i made it so that when the player died he reset his position like @Acdia said

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

135 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Force enemy to fire at a specific point, == appears not to work. 2 Answers

fps shooting enemy 1 Answer

Enemy needs to shoot precisely at player 2 Answers

how can i destroy a cube when i press a gui button??? 1 Answer

Enemy Detects Buildings? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges