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
1
Question by Flavio · Feb 25, 2011 at 12:28 AM · charactercontrollermultiple

Multiple players on single controller

I'm working on a game where you have multiple (3) characters, which are all controlled by a single player. Something like the Lost Vikings. How can I isolate the input so that only one moves at a time, and when a certain key is pressed, the control shifts to other charcter?

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

2 Replies

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

Answer by by0log1c · Feb 25, 2011 at 04:26 AM

What I'd do:

  • create a built-in array characterList holding characters GameObjects.
  • create a private boolean variable isActive, or something.
  • create a int variable activePlayer or something.

  • character [0] has isActive = true. other characters have it to false.

  • in the Update() of the character script, only process Input if isActive==true.
  • every time player hit a certain key,go to next activePlayer:int; activePlayer++;

  • in the Update() of the character script, if isActive==false, make the character follow the active one.

something like that. Of course there's plenty of(better) way to do this but its definitly feasible.

Comment
Add comment · Show 1 · 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 Flavio · Feb 25, 2011 at 07:14 PM 0
Share

Thank's that worked out. If it is inactive I just leave them standing there. I had to do a little tweaking, because just disabling the control input processing kept them going ins$$anonymous$$d of stopping them...

avatar image
0

Answer by cregox · Feb 25, 2011 at 01:38 AM

From my experience, it's much easier to leave all the characters being controlled at same time and just keep 2 of them off the screen. When you switch, just change positions. I know it's hackish, but it works.

Comment
Add comment · Show 2 · 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 Flavio · Feb 25, 2011 at 02:25 AM 0
Share

Can't really do that. The characters will interact with each other. By the way, it is 3rd person view...

avatar image cregox · Feb 25, 2011 at 08:50 PM 0
Share

@Flavio I see. Sorry. I haven't realized before what you meant and don't know about Lost Vikings, but now I think like Secret of $$anonymous$$ana. Prior I was thinking something more like Trine. But it wouldn't matter if it's 1st person, 3rd person, 2D or 3D.

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

No one has followed this question yet.

Related Questions

Grab/Push Rigidbody with CharacterController 0 Answers

how to make my character go round loops? 1 Answer

Please help me finish my 3rd person rigid body controller! 0 Answers

Damage Player when this object collides the CharacterController? 2 Answers

CharacterCOntroller or RigidBody ?? 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