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 /
avatar image
0
Question by Nightm4reProds · Oct 10, 2017 at 01:58 AM · fpsfps controllernpcswitchingcamera controls

Change between players with a button

Hi :D Im trying to make a game of which I'll not say in what it consists since I think its a very good idea but I have problems to do it... x)

Well, the thing is that I have to "switch" position with an npc and control it. I dont actually know how should I do this since I dont find the way to change the camera in the FPS Controller. It'd be something like this.

I aim to another "npc"(rn it'd be just a box), click G and Im "him". I've tried searching and I found some things like that but none seems to work properly...

http://answers.unity3d.com/questions/16146/changing-between-cameras.html

http://answers.unity3d.com/questions/239700/switch-camera-on-input-in-c.html

http://answers.unity3d.com/questions/14381/main-camera-switch.html

Thanks in advance.

Comment
Add comment · Show 1
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 Nightm4reProds · Oct 10, 2017 at 09:31 PM 0
Share

Just found the way to change the camera. The next step is to make the other "player" to move. Thanks anyway :).

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class FifthSouls$$anonymous$$ovController : $$anonymous$$onoBehaviour {

 //CA$$anonymous$$ARA
 public Camera FPSCamera;
 public Camera FPSCamera2; 


 public float horizontalSpeed;
 public float verticalSpeed;


 float h;
 float v;



 //$$anonymous$$OVI$$anonymous$$IENTO
 public float run = 1;

 public int forceConst = 4;

 private bool canJump;
 private Rigidbody selfRigidbody;


 // Use this for initialization
 void Start () {
     //CA$$anonymous$$ARA
     FPSCamera.enabled = true;
     FPSCamera2.enabled = false;


     //$$anonymous$$OVI$$anonymous$$IENTO
     selfRigidbody = GetComponent<Rigidbody> ();


 }

 void FixedUpdate (){
     if (canJump) {
         canJump = false;
         selfRigidbody.AddForce (0, forceConst, 0, Force$$anonymous$$ode.Impulse);
     }
 }





 // Update is called once per frame
 void Update () {

     //CA$$anonymous$$ARA
     h = horizontalSpeed * Input.GetAxis ("$$anonymous$$ouse X");
     v = verticalSpeed * Input.GetAxis ("$$anonymous$$ouse Y");

     transform.Rotate (0,h,0);
     FPSCamera.transform.Rotate (-v,0,0);


     if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.G)) {
         FPSCamera.enabled = !FPSCamera.enabled;
         FPSCamera2.enabled = !FPSCamera2.enabled;
     }







     //$$anonymous$$OVI$$anonymous$$IENTO
     if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.W)) {
         transform.Translate (0, 0, 0.1f * run);

     }
     if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.D)) {
         transform.Translate (0.1f * run, 0, 0);

     }
     if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.A)) {
         transform.Translate (-0.1f * run, 0, 0);

     }
     if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.S)) {
         transform.Translate (0, 0, -0.1f * run);

     }
     if (Input.Get$$anonymous$$ey ($$anonymous$$eyCode.LeftShift)) {
         run = 2;
     } else {
         run = 1;
     }
     if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.Space)) {
         canJump = true;
     }





     
 }

}

0 Replies

· Add your reply
  • Sort: 

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

142 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

Related Questions

Full body gun switcher for animations? 1 Answer

Parented Object moves weirdly in FPS Standard Asset Camera 0 Answers

How Do I Get My Player To Move With The Block That Its On 1 Answer

First person shooter : Footsteps! 1 Answer

Y Mouse Movement without the tilting 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