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 machinew · Feb 18, 2011 at 06:37 PM · charactercharactercontroller

second character controller ???

Hello everybody,

i want a make switchable character controllers and i try something like this

var Character1 : GameObject;

var Character2 : GameObject;

function Update () {

if(Input.GetKeyDown ("1")) Character1.GetComponent(CharacterMotor).enabled = true; Character2.GetComponent(CharacterMotor).enabled = false;

if(Input.GetKeyDown ("2")) Character1.GetComponent(CharacterMotor).enabled = false; Character2.GetComponent(CharacterMotor).enabled = true; }

when i pressedd key 1 two controller move together

but when i pressed key 2 its work perfectly

how can i fix that (thats my firspost sory about everything)

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

4 Replies

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

Answer by Mike 3 · Feb 18, 2011 at 07:02 PM

You're missing braces to specify which parts are in the if:

if(Input.GetKeyDown ("1"))
{
    Character1.GetComponent(CharacterMotor).enabled = true;
    Character2.GetComponent(CharacterMotor).enabled = false;
}
if(Input.GetKeyDown ("2"))
{
    Character1.GetComponent(CharacterMotor).enabled = false;
    Character2.GetComponent(CharacterMotor).enabled = true;
}
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 machinew · Feb 18, 2011 at 07:39 PM 0
Share

thank you so much $$anonymous$$ike

avatar image
0

Answer by machinew · Feb 18, 2011 at 07:49 PM

i have a another little problem when i played the game characters move together i want a make only Character1 is enable i tried

var Character1 : GameObject;
var Character2 : GameObject;
var Chaarcter1Enabled = true;
var Chaarcter2Enabled = false;

how can i fix it ? Thank you again

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 Unamine · Feb 18, 2011 at 10:35 PM

Try this:

var Character1 : GameObject; var Character2 : GameObject; var isActive1 = false; var isActive2 = false;

function Update () {

if(Input.GetKeyDown ("1") && isActive2 == true || isActive2 == false) { Character1(); }

if(Input.GetKeyDown ("2") && isActive1 == true || isActive1 == false) { Character2(); }

function Character1() { Character1.GetComponent(CharacterMotor).enabled = true; Character2.GetComponent(CharacterMotor).enabled = false; }

function Character2() { Character1.GetComponent(CharacterMotor).enabled = false; Character2.GetComponent(CharacterMotor).enabled = true; }

any questions post here again.

Hope that helps

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 machinew · Feb 19, 2011 at 11:01 AM

i just uncheck Character 2 Character Motorin the inspector panel and its work

Thank You Guys

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

No one has followed this question yet.

Related Questions

Character controller + animation of different meshes making one character 1 Answer

How can I implement a SimpleMove max speed? 1 Answer

Character Controller Movement With WASD 1 Answer

Issue with Character controller and skin width 2 Answers

New to Unity and have questions about creating a Virtual World 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