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 Polatrite · Dec 17, 2009 at 05:08 AM · camera2d-tutorial

2D Tutorial - Camera reorients itself on startup, no focus

Hello, I am new to the boards. I have a few years (2001ish) experience doing game development with other platforms such as BYOND and Gamemaker, but now that Unity is free I'm definitely interested in checking it out.

I picked up the 2D tutorial because I think it will be easiest to work with 2 dimensions in a 3D environment, since all my other work has been 2D.

But on to my problem! I might be an idiot (you tell me), but essentially I have followed the 2D Tutorial up through page 20, which is where I add and configure the camera.

When I run the game, the camera briefly (0.3~ seconds) focuses on whatever it was positioned at in the scene window, then immediately warps to some other position. If I watch it in the inspector, here's what happens:

Starts at -10,80,-15 then warps to 8,15,-15 (with some decimals) and then slowly climbs to 8,51,-15, as if it's deaccelerating after focusing on something.

I gave the Main Camera the CameraFocus and CameraScrolling scripts, I set my Target to "Character (Lerpz)" with the vector icon (not the cube icon), and I set the Target Button Name to "Player".

Every object in the hierachy has a Z index of 0 (except the camera, which is -15 and seems to correspond with the "distance" variable of the CameraScrolling script, too.

Lerpz is placed properly, and he actually falls onto the platform (I can see in the inspector) and I can make him move around, but the entire time the camera is just looking off into the skybox somewhere.

Any ideas what I screwed up? =D

I originally posted this on the forums before I realized this is the better place for answers: http://forum.unity3d.com/viewtopic.php?t=39425

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 Ehren · Dec 22, 2009 at 09:55 PM 0
Share

It might help if you could post your project somewhere.

2 Replies

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

Answer by AndrewS · Dec 31, 2009 at 01:16 PM

I had this problem too.

The cause seemed to be that the CameraFocus script is picking up the wrong target; there's both the prefab named 'Character (Lerpz)' as well as the GameEntity with that name. Choosing the correct entry (the game entity) from the popup in the Targets array doesn't seem to work, because the script won't find the correct target when it runs.

To fix the problem: Rename the character to something different (Lerpz, George, Asdf) and then change the target element (Element 0, in the Camera Focus script pane) to point to the renamed entity. The camera will then work proper.

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 MikeB · Dec 17, 2009 at 02:18 PM

I haven't played with that tutorial specifically, but I would guess: the values in the transform attached to the Main Camera are the starting position; the scrolling / accelerating behaviors are controlled in the CameraScrolling script to smoothly adjust the position, and the transform of the Target is going to be the look-at location for the camera.

If you want the camera to not warp around on start up, you need to adjust the camera position so that it is approximately where it should start (which, according to your post, is where the camera ends up converging : 8,51,-15; I would guess that Lerpz' starting position is near 8, 51, 0?

As to why it isn't looking at anything, I would say try modifying the z position from -15 to +15; or adjusting the rotation of the camera so that it is pointing down the z axis (which would be a 90 degree rotation around the y axis, I think).

You can adjust things while the game is running by changing variables in the inspector, but remember that those changes will revert as soon as you stop the game, so once you find the right values you have to re-apply them.

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 Polatrite · Dec 17, 2009 at 02:30 PM 0
Share

Thanks $$anonymous$$ike,

I actually already set the camera to the appropriate location, Lerpz starts around -10,80,0. When I put the camera at this place (-10,80,-15), it simply warps to the 8,15,-15 and does the movement like I already described. The camera Z seems alright - I can see the platform briefly before the camera warps downward and never returns, if I manually position the camera (and disable the CameraScrolling and CameraFocus scripts) it will view the character just fine.

It's just that those scripts don't appear to be working correctly, even though they are out-of-the-box for the tutorial.

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

How to make camera position relative to a specific target. 1 Answer

uGUI culling layers alternative 0 Answers

Calculating perspective camera size at depth 1 Answer

what to change that the camera does not move on the y-axis 1 Answer

Why can't I change my camera's position? 2 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