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 /
avatar image
0
Question by rahulpatil6220375 · May 18, 2019 at 09:41 AM · camerapositionchange

How can camera Forward Or How to change position of camera?

i m working on 3D game,i take 4 home in level1,and take 4 home in level2, in level1 when home1 empty space fillup complete. what can i do when complete fill up empty space home 1 then camera should be going on home 2?? what can i do for this..?? or how to change position of camera??

Code:

  public Camera cams;
 
 void fixedupdate()
 {
      gameover();
 }
 void gameover()
 {
     //some code here
     //camera position change code
     Vector3 positions =  cams.transform.position + new Vector3(-12, 0, 0);
     Debug.Log("position" + positions);
 }

Referance:

alt text

//camera position change but camera not move alt text

cameraposition.png (65.6 kB)
camera.png (68.1 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Doctor_ED · May 18, 2019 at 11:09 AM

In the :

  void gameover()
  {
      //some code here
      //camera position change code
      Vector3 positions =  cams.transform.position + new Vector3(-12, 0, 0);
      Debug.Log("position" + positions);
  }

you are only calculating new position for the camera, and not applying it to camera gameObject. To fix it :

 void gameover()
      {
          //some code here
          //camera position change code
          Vector3 positions =  cams.transform.position + new Vector3(-12, 0, 0);
          cams.transform.position = positions;
          Debug.Log("position" + positions);
      }

Comment
Add comment · Show 3 · 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 rahulpatil6220375 · May 18, 2019 at 11:15 AM 0
Share
  public Camera cams1;
     private Vector3 secondhome= new Vector3(5.6f,19f,2.7f);
     private Vector3 thirdhome = new Vector3(-10,19,2.7f);
     private Vector3 fourthhome = new Vector3(-22,19,2.7f);


exactly but problem was there i have only one camera

what i m trying to do now: cams1.transform.position = secondhome; //when first complete then second

firstcomplete then second come but third and fourth home not come when second complete??

avatar image Doctor_ED rahulpatil6220375 · May 18, 2019 at 01:27 PM 0
Share

It's a bit messy. I'm not sure if I understand what you are trying to do, but I assume that you just want to move camera to next home, after fininshing previous one. If so :

 [SerializeField]
 private Camera cam;
 [SerializeField]
 private Vector3[] homesPositions =
 {
     new Vector3(5.6f,19f,2.7f),
     new Vector3(-10,19,2.7f),
     new Vector3(-22,19,2.7f)
 };
 private int nextHomeIndex = 0;
 
 private void NextHome()
 {
     if (nextHomeIndex < homesPositions.Length)
     {
         cam.transform.position = homesPositions[nextHomeIndex];
         nextHomeIndex++;
     } else
     {
         //You are already in the last home
     }
 }

Call the NextHome() when player finishes given home.

avatar image rahulpatil6220375 Doctor_ED · May 19, 2019 at 12:25 PM 0
Share

alt text

home1 bydefault active when player finish home1 then active home2(home 2 complete) and then active home 3(home 3 complete) and then active home4(home4 complete) then how can i move the player going next level???how can i manage my home??

  private Vector3 firsthome = new Vector3(17.6f,19,2.7f);
  private Vector3 secondhome= new Vector3(5.6f,19f,2.7f);
  private Vector3 thirdhome = new Vector3(-10,19,2.7f);
  private Vector3 fourthhome = new Vector3(-22,19,2.7f);

 public GameObject home1;
 public GameObject home2;
 public GameObject home3;
 public GameObject home4;

       if (complete.Length == 0)           // (8==8)
         {
            //when first homecomplete then second homeactive
             cam.transform.position = secondhome;      
              //home1 complete then home1 inactive
             home1.SetActive(false);                  
             //home1 complete then home2 active
             home2.SetActive(true);                   
             
             $$anonymous$$yGameOver();
             Debug.Log("inside the completecall");
         }

how to manage my third and fourth home???

home.png (20.8 kB)

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

182 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 avatar image avatar image avatar image avatar image 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

throwing a ball camera position changes 0 Answers

Change position - cameras - slider 1 Answer

I make a camera that change position every X seconds but i need different waiting time for each position that take. 0 Answers

lock position - relative to camera 1 Answer

Child GameObject is aligned to world axis and not the parents axis (UPDATE) 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