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 davidc · May 02, 2013 at 02:11 PM · camerajavascripttransformside-scrolling

Camera, Offsetting the Transform.LookAt

Hey People, ive got a very basic script for my Main camera to follow my player. im creating a 2.5D platformer and im doing allot of fine tuning atm.

here is my code

 var Target : Transform; 
 var distance = 5;
 
 function LateUpdate () { 
    transform.position = Target.position + Vector3(0, distance, -30); 
    transform.LookAt (Target); 
     }

At the moment the ground/floor, takes up 50% of the screen real-estate. I want it to take up much less, is there a simple command i can use to do this? i have fiddled around with the (0, distance, -30) part but it isn't relevant.

Any Suggestions?

alt text

screen shot 2013-05-03 at 12.06.49 am.jpg (98.8 kB)
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 ExTheSea · May 02, 2013 at 05:32 PM 1
Share

Hey davidc your question just keep popping up in my mail inbox :)

Hm. Does it really not change when you put something else as the distance variable like 100.

If not you could try to add something like

 transform.position = Target.position + Vector3(0, 0, -30) + (Vector3.up * height); //I called it height not distance here because it makes more sense to me

2 Replies

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

Answer by robertbu · May 02, 2013 at 08:24 PM

Your problem is the transform.LookAt(). You can move the camera up and down, but if you use a LookAt(), the camera is going to be tilted so that you character is in the center of the screen. How you solve this will depend on how you want camera to follow the character. As a start, take out the transform.LookAt() and adjust the Vector3(0,distance,-30).

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 davidc · May 03, 2013 at 02:58 AM 0
Share

AHHH, thank you guys, it was the transform.lookat that was the problem, i didn't realize i didn't need it for what im doing. thank you

avatar image
0

Answer by angelonit · Mar 02, 2014 at 05:15 AM

I had this problem in a 3D environment and I found the solution to be to move the camera after the lookat:

Vector3 lokat = camTarget.position; transform.LookAt(lokat); transform.position+=Vector3.up*0.9f;

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

14 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

Related Questions

Move an object toward an angle in 2d space 0 Answers

Pan Orthographic Camera 0 Answers

Setting Scroll View Width GUILayout 1 Answer

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Object reference not set to an instance of an object 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