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 Rozenkai · Nov 14, 2014 at 01:38 PM · c#instantiatepositionvector3checkpoint

help with checkpoint sytem C#

trying to instantiate an my player when the level starts at a object location this is and when i hit the checkpoint it moves the spawnpoint location so if the player dies i can hit gameover screen then loop round to checkpoint instead of starting again i know i could just create a new scene but would bulk out the project to much

so i thought if i spawn player at start of level at an empty gameobject spawn point then when the checkpoint is hit it moves the spawnpoint to new location then when the level resets the player spawns there heres what ive got so far any help would be great

using UnityEngine; using System.Collections;

public class Checkpoint : MonoBehaviour {

 public GameObject CheckP;
 public Vector3 CheckPos;
 public GameObject player;
 public Transform SpawnPosition;
 public GameObject SpawnPoint;




 void awake(){

     DontDestroyOnLoad(SpawnPoint);

     }
 void start(){

             Instantiate (player,SpawnPosition,Quaternion.identity);
     }

i need way to move spawn ontrigger and a way to make the transform a vector 3 thnx

 void OnTriggerEnter2D (Collider2D other)
 {

     if (other.tag == "Player")
         Instantiate(CheckP, CheckPos, Quaternion.identity);
         Debug.Log ("hit");
         

 }

} i need a way to transform the spawnpoint on trigger and a way to make the spawn position transform a vector 3 ive tried the unity docs but it want numbers for public vector 3 and transform is not accepted in the instantiate :P

Comment
Add comment · Show 3
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 FairGamesProductions · Nov 14, 2014 at 01:56 PM 0
Share

Why do you need "a way to make the spawn position transform a vector 3" if you're using 2D Triggers? Isn't your game 2D?

avatar image Rozenkai · Nov 15, 2014 at 02:44 AM 0
Share

it doesnt really its just when i type instantiate it says it needs a gameobject ,vector3, Quaternion.identity so thats what ive been using but ur right it is 2d so if there is other way please let me know

avatar image richyrich · Nov 15, 2014 at 04:45 PM 0
Share

If ins$$anonymous$$d of destroying the player object, you just disabled and then reset location (Vector2) to last checkpoint, you would not need to instantiate anyway, which would then remove the problem wouldn't it?

2 Replies

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

Answer by Haythamcrc · Nov 15, 2014 at 05:31 PM

1- Create empty gameobject name it --- SpawnPoint 2- Create another gameObject name in --- CheckPoint

Add this Script to CheckPoint :

 using UnityEngine;
 using System.Collections;
 
 public class CheckPointScript : MonoBehaviour 
 {
     public Transform SpawnPoint;
 
     void OnTriggerEnter2D(Collider2D col) 
     {
         if(col.tag =="Respawn")
             
         {
             SpawnPoint.position = new Vector3(transform.position.x, transform.position.y, SpawnPoint.position.z);
 
         }

        
         
         
     }
 }

3- Add Box Collider 2D to CheckPoint with Is Trigger.

I hope this will help you :)

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
avatar image
0

Answer by FairGamesProductions · Nov 15, 2014 at 05:07 PM

If, your game is 2D, then use Vector2.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Instatiating a prefab in a random position 0 Answers

Position + Vector3 doesn't return correct values 1 Answer

Position in Vector (C#) 1 Answer

How to Check if any object is at an specific Vector3? 1 Answer

position.Set vs. position = new Vector3() 0 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