Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
This question was closed Mar 29, 2019 at 01:48 AM by siones1172.
avatar image
0
Question by siones1172 · Mar 29, 2019 at 01:39 AM · selection

Character selection for a team??

Alright, so I have a character select scene and I have 4 platforms with buttons for a player to choose between 4 characters to make a team. I have a character container and a script for selecting the characters and buttons that represents each character. Almost everything is working but my first problem is I can only select one character and my second problem is referencing the selected character and setting them active in the position and rotation of the selected platform. For my first problem I was thinking of adding an array, but I need help executing it as well as I need help transforming the position of the selected character. My script that works is

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class CharacterContainer : MonoBehaviour
 {
     private List<GameObject> characters;
     private int selectionIndex = 0;
 
     private void Start()
     {
         characters = new List<GameObject>();
         foreach(Transform t in transform)
         {
             characters.Add(t.gameObject);
             t.gameObject.SetActive(false);
         }
 
         characters[selectionIndex].SetActive(true);
 
     }
 
     public void Select(int index)
     {
         if(index == selectionIndex)
             return;
 
         if(index < 0 || index >= characters.Count)
             return;
 
         characters[selectionIndex].SetActive(false);
         selectionIndex = index;
         characters[selectionIndex].SetActive(true);
     }
 }
 

And the edits that I began on the script are

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class CharacterContainer : MonoBehaviour
 {
     private List<GameObject> characters;
     private int selectionIndex = 0;
     public Transform Player1SpawnPoint;
     public Transform Player2SpawnPoint;
     public Transform Player3SpawnPoint;
     public Transform Player4SpawnPoint;
     public bool platformActive;
 
     private void Start()
     {
         characters = new List<GameObject>();
         foreach(Transform t in transform)
         {
             characters.Add(t.gameObject);
             t.gameObject.SetActive(false);
         }
 
         characters[selectionIndex].SetActive(true);
 
     }
 
     public void Select(int index)
     {
         if(index == selectionIndex)
             return;
 
         if(index < 0 || index >= characters.Count)
             return;
 
         characters[selectionIndex].SetActive(false);
         selectionIndex = index;
         characters[selectionIndex].SetActive(true);
     }
      //////Transform the position on selected platform
      if (platformActive)
 {
 characters[selectionIndex].transform.Translate(Player1SpawnPoint.position, Player1SpawnPoint.rotation;)
 }
 }
 

I was gonna have 4 platformActive listed, but the first one didn't work. I hit a wall.

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

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

166 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 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

instantiating player to different scenes 0 Answers

Plane character selector unity problem 0 Answers

Selection Outline/Wire missing in only one scene. Gizmo settings are correct, tried resetting layout. 0 Answers

So I know this has been asked before but, I feel this only applies to my problem. 2 Answers

How do I save a previously bought characters in my Game? 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