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
1
Question by CrossRiverGames · Aug 09, 2013 at 04:20 PM · cameraspritedisplay

Sprite not displaying when I add a line of code that moves the main camera to another sprite

I'm in the beginning stages of writing a game and I'm having a bit of a problem. What is supposed to happen at this point is that the player sprite should fall towards the bottom of the screen with the main camera following and both the player and the camera should stop if the player collides with an obstacle. What is actually happening is that I can either have the player fall and collide with the obstacle but have the camera not follow or have the player fall and collide with an invisible obstacle and have the camera following.

I've narrowed down the problem to this code section: // Move vertically endPoint.Set(startPoint.x, startPoint.y - speed, startPoint.z); // Calculate the end point. Z never changes because this is a 2D game. X is changed via player input. transform.position = Vector3.Lerp(startPoint, endPoint, (Time.time - startTime) / duration); // Move the sprite camera.transform.position = Vector3.Lerp(cameraStartPoint, endPoint, (Time.time - startTime) / duration); // Move the camera speed = speed * rate; // Increase the speed

If I comment out the line starting with "camera" then I can see the obstacle, but the camera does not follow the player. If I do not comment it out, the camera follows the player but I cannot see the obstacle.

Click this link for a video showing the problem.

Any help would be greatly appreciated. Thank you!

Douglas Pope

Cross River Games

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 CrossRiverGames · Aug 09, 2013 at 06:20 PM 0
Share

Lovrenc:

Thanks for your suggestions. I paused the game and rotated the camera like you suggested, and it looks like the player and the obstacle are coplanar, with the plane in question being parallel to the Y-axis. However, they are not; the player has a Z-value of 0 and the obstacle has a Z-value of -0.3. $$anonymous$$aybe that's the problem? The camera is orthographic, so the second suggestion does not apply.

EDIT: That was the problem! Thanks for the help!

1 Reply

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

Answer by Lovrenc · Aug 09, 2013 at 07:44 PM

Only 2 things come to mind:

  1. Camera somehow gets rotated and your obstacle doesent have normals to face camera.

  2. Camera gets moved to close to show obstacle. If it is ortographic make sure object is not behind the camera, if it is not orthographic, than you also have to take in account camera may be to close to get your object into the cone it records.

Start your game and pause it and then spin things around in editor view and see what is happening.

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

16 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

Related Questions

MissingComponentException: There is no 'Camera' 0 Answers

Please help to have a Game View running in multiple displays: one main display plus two external target displays. 1 Answer

Camera issue (storing temp variable C# problem) 3 Answers

2D - FollowCam causes player sprite to disappear 0 Answers

How can I make a layer black? Unity 2D 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