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 BobbleHead · Jun 25, 2011 at 11:28 AM · 2dtopdown

changing top down cameras position as such

I'm trying to make a top down shooter, similar to that of the old classics (DoDonPachi, 19xx etc), i've got my movement code, projectile code and camera code, but within the camera code there is a problem, a problem in the sense that the player is not at the bottom of the screen centered, but instead center to the screen, Ive tried to edit code to change this, but no luck, below is my original code, any ideas on what/how to change would be greatly appreciated.

 var height = 20.0;
 var distance = 0;
 var target : Transform;
 
 function Update () {
 transform.position = target.position;
         transform.position.y += height;
         transform.position.z -= distance;
         transform.LookAt(target.position);

}

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

Answer by Ashkan_gc · Jun 25, 2011 at 11:38 AM

when you use LookAt this will happen and the object that you are looking at will be in center of the screen and using height and distance you can only change viewpoint angles.

you should change the x axis rotation of the camera to 90 (downward) and then put your code without look at. in this way you can find a distance (less than zero) that will do what you want. just remove lookat and rotate camera to look downward (toward ground).

to place a camera in a position that a certain object be in a special position in screen space, you should solve some equations which are not needed here at all.

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 BobbleHead · Jun 25, 2011 at 01:47 PM

 var height = 20.0;
 var distance = -1;
 var target : Transform;
 
 function Update () {
 transform.position = target.position;
         transform.position.y += height;
         transform.position.z -= distance * height;
 }

not perfect but this code will do the job for anyone who needs it.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How can I make 2D movement less jerky on a controller, with velocity and such? 0 Answers

Hover over text VERY glitchy 0 Answers

How to apply light on post processing volume 0 Answers

I have an animaiton problem about sprite loading. 0 Answers

Player spawn point not working. 0 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