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 Cbjfan1 · Aug 08, 2012 at 01:00 AM · spawnclasscustomchoose

Left 4 Dead-style Spawnpoints?

Hi everyone. I need help with making a game where one person has to get to the other side of the map, and the other person tries to stop him. The person trying to stop him can choose from physical being, or paranormal. Physical being opens up several monsters to choose from. I have all the players set up, I just need some help with the classes and spawning.

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 Bunny83 · Aug 08, 2012 at 01:24 AM 1
Share

I'm not sure what kind of help do you expect? It depends on your gamedesign how you want the spawnpoint selection.

For example here's an interactive simulation where a player can spawn in Quakelive(Campgrounds) that you have fragged.

Do you want them to spawn between the survivors and the final target? Does the map has some kind of path? There are hundreds of variables which you have to define before you start to implement a certain spawn rule.

Do you remember? Clear and detailed questions...

avatar image irrationalistic · Aug 08, 2012 at 03:45 PM 2
Share

This is somewhat generic, but does get into the placement and planning of zombies and special infected in the L4D game. PDF by $$anonymous$$ike Booth of Valve: http://www.valvesoftware.com/publications/2009/ai_systems_of_l4d_mike_booth.pdf

avatar image Bunny83 · Aug 08, 2012 at 04:13 PM 0
Share

@irrationalistic: This is a great paper from one of my favourite gamedevelopers ;)

avatar image Cbjfan1 · Aug 08, 2012 at 06:26 PM 0
Share

I'm trying to keep it simple. The humans spawn of one side of the map, the creatures on the other. All I need help of is a sort of "Selection menu" for each of the playable people

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Aug 09, 2012 at 03:23 AM

Well, since you actually don't want Left4Dead style spawnpoints but simple multiplayer spawnpoints, you can use something like that:

 // C#
 // SpawnPoint.cs
 using UnityEngine;
 using System.Collections.Generic;
 using System.Linq;
 
 public enum Team
 {
     Survivor,
     Infected
 }
 
 public class SpawnPoint : MonoBehaviour
 {
     // players should be on custom layer 8 so they can be
     // detected if they block a spawn point
     private static int m_PlayerLayer = 8;
     
     // range around the spandpoint which should be empty to use this spawn point
     private static float m_ClearRadius = 2.0f;
     
     // Set in the inspector
     public Team team = Team.Survivor;
     
     public bool IsThisPointClear()
     {
         var players = Physics.OverlapSphere(transform.position, m_ClearRadius, 1 << m_PlayerLayer);
         return players.Length <= 0;
     }
     public static SpawnPoint FindFreeSpawnPoint(Team aTeam)
     {
         var spawns = FindObjectsOfType(typeof(SpawnPoint)).Cast<SpawnPoint>().Where(O => O.team == aTeam).ToList();
         while (spawns.Count > 0)
         {
             int i = Random.Range(0,spawns.Count);
             if (spawns[i].IsThisPointClear())
                 return spawns[i];
             spawns.RemoveAt(i);
         }
         return null;
     }
 }

Just place some empty gameobjects in the scene, attach this script and select the team for each spawnpoint.

Now you can simply use this when ever you need a spawn point:

 var SP = SpawnPoint.FindFreeSpawnPoint(Team.Survivor);
 if (SP == null)
 {
     Debug.LogError("All spawns occupied and / or not enough spawn points");
     return;
 }
 Instantiate(playerPrefab, SP.transform.position, SP.transform.rotation);
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

9 People are following this question.

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

Related Questions

How do we create a custom class in scripting? 1 Answer

Spawn object problem 1 Answer

Inspector button for custom class 1 Answer

Magic Spell Types - SpellType.Fire/Water/Earth? 1 Answer

How to change scripts to include Waves of Enemy? 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