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
1
Question by Novrick · Sep 12, 2011 at 10:39 AM · cameraposition

Camera problem

I want the camera to be over the level after I press space in a specific area. But when I play the game, go to the area and hit space...it's position goes somewhere else (can only see white, the color I chose to be in the background).

does the error come from that I fixed the cameras position to the player?

here is the code:

void OnTriggerStay(Collider other) {

     //print("VI ER PO GONG!");
     if(Input.GetKey("space"))
        {
         
             //print("VI E LADDADE!");
             Camera.main.transform.Translate(100,82,26);
         
        }
     
 }


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
0
Best Answer

Answer by japanitrat · Sep 12, 2011 at 10:48 AM

Translate moves the transform relative to its previous position. When the key is pressed (more than one frame) the camera moves, moves, moves, moves, and moves again. Either you use absolute coordinates (transform.position) or you try it with Input.GetKeyDown, which is only fired once

Comment
Add comment · Show 6 · 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 Novrick · Sep 12, 2011 at 12:23 PM 0
Share

I tried changing the code to:

camera.main.transform.position(100,82,26)...but I only get an error =/

avatar image japanitrat · Sep 12, 2011 at 06:32 PM 0
Share

Yes, cause position is an instance of Vector3 and not a method. Try this:

camera.main.transform.position = new Vector3(100, 82, 26);

avatar image Novrick · Sep 12, 2011 at 08:14 PM 0
Share

tried that to, still white =S

avatar image japanitrat · Sep 12, 2011 at 08:51 PM 0
Share

would you please position your camera at these coordinates and check if it is also white if you manually position it?

avatar image Novrick · Sep 13, 2011 at 07:12 AM 0
Share

ah....now I see the problem. the position is right, but not the rotation. Now I only need to figure out how to change position and rotation

Show more comments
avatar image
0

Answer by Ludiares.du · Sep 12, 2011 at 10:49 AM

In your script you're moving the camera, not positioning it. Instead try using:

 Camera.main.transform.position(100,82,26);
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 Novrick · Sep 12, 2011 at 12:21 PM 0
Share

I tried with position, but it only gets an error reading: Unityengine.Transform.position cannot be used as a method or delegate

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Adding y position? 4 Answers

RTS Camera movement wrong after rotation 1 Answer

How can i freeze the camera in Google cardboard? 0 Answers

throwing a ball camera position changes 0 Answers

How can I get exact screen position of 3D game object in front of camera while using cardboard in VR game? 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