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 bluesheep4 · Nov 10, 2020 at 12:58 AM · spawnfps controllerspawning problemsspawnpoints

Multiple Spawn Points for fps character

Hi so Im attempting to make an fps with a maze for a map, and I'm wanting to make multiple character spawning points in the same room(scene), depending on which room(scene) you previously came from. So with a maze say in one room you have 4 different doors leading to it, and depending on which room you exited from, you will need a different spawn point, so as to not be confused on where you come from. I have done some very basic coding, but this is little beyond me, and need some guidance. I have a "DoorManager" script that persists through different scenes, although im not sure I will need it or not.

I would like to say something like if ive left room A, then spawn in room B @ thispoint else if i've left room C, then spawn in room B @ this point

so it would be like if ive gone from one specific scene to another specific scene, i would respawn at this specific point.

Ive also considered using empty objects and tags, so setting the individual empties infront of the doors, depending on which one i trigger, the next scene i would spawn a specific place corresponding with said trigger?

I hope these help, but if anyone has ideas pleas share them, also in your code pls be a detailed as possible, not like to an unnecessary amount i just can't always interpolate the information into workable C# bc im not well versed in it yet

Thank you sm!!!!!

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by jackmw94 · Nov 10, 2020 at 01:03 PM

If you door is as simple as 'if player enters this doorway, teleport them to a new position' then you could just have a script like this:

 public class Door : MonoBehaviour
 {
     [SerializeField] private Transform _doorTarget;
 
     private void OnTriggerEnter(Collider other)
     {
         if (other.gameObject.name.Equals("Player"))
         {
             other.transform.position = _doorTarget.transform.position;
         }
     }
 }


This would require the gameobject to have a collider on it - an easy way to set this up would be to make a cube, add this script then disable the mesh renderer once you've repositioned and resized it.
The if-statement could be any check that determines whether the object that's entered the door is the player object; could check whether the object has a player-specific script on or whether it has a certain tag. If you're using this name check then make sure to change "Player" to whatever your player is called!

If your character has a character controller on it then this will disrupt manual positioning like we're doing above so you can alter it like so:

 private void OnTriggerEnter(Collider other)
 {
     var characterController = other.GetComponent<CharacterController>();
     if (characterController)
     {
         characterController.Move(_doorTarget.transform.position - other.transform.position);
     }
 }
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

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

Related Questions

How to prevent multiple spawns from a single spawn point? 1 Answer

How do I spawn more the one spawnpoints ramdomly in my scene / Spawning problems 0 Answers

Is it possible to instantiate a prefab in 2d game from particular locations without using empty game object? 2 Answers

[Help] How Do I Randomly Spawn Game Objects On Specific Coordinates? 3 Answers

Spawning help 1 Answer


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