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 Sam-Spohn · Oct 08, 2016 at 07:13 PM · world3rd person cameraround

How to calculate/find/get a normal vector from an object to a round planet to use in angle calculations/ 3D movement/etc..

I am just starting to build a game where the player controls a tank on a round world/planet. I have implemented a gravity script that pulls objects to the planet. the tank falls and drives around and I even put a "moon" in orbit. problems occur with moving the tank with respect to a third person camera. the tank will move away from the camera when pressing w, toward with s, left of with a and right of with d. this is sort of what I want, but examples of the issue are, if you angle the camera up (to shoot up into the air) and press forward, your tank will fly. as impressive as a flying tank is, it is not what i want to happen. the same thing will happen while looking down and moving backward. if you manage to roll the tank on its side, flying can be achieved by pressing the left or right key that faces away from the surface.

I want to use this "normal" vector to calculate if I need to automatically roll the tank in the upright position ( which itself is not calculable without the vector). i would like to use it to check if the tank's z and/or x angle is greater than 90 and less than 270 (fallen too far right or fallen too far left. If the angle of the tank is in between these angles it is sideways or upside down). It is difficult or impossible to decide the upright direction of the tank in worldspace because, starting on the "upright" side of the planet and going to the opposite side of the world, the tank would be upside down, or going to the equator would yield angles 90 degrees to upright.

I want to maybe use it to get the forward direction relative to the camera, regardless of its height to the tank. if I look down (or up) I want to move forward tangent to the surface I am on but still forward with respect to the angle the camera is facing.

I would like to keep the camera somewhat unbound to the tank. if I'm going up a hill, I want the camera to consider the normal angle rather than the tank. I want 0 degrees elevation of the camera to be tangent to the world. (effectively if the tank goes up a hill, and the camera is at 0 degrees, I should be able to see its roof).

How would I go about implementing this.I am very lost.

Thanks for your answers.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Sam-Spohn · Oct 12, 2016 at 03:24 AM

never mind, figured it out. give me a while and I'll let anyone who wants to know in on the secret.

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

Can unity create a continuase world?? 3 Answers

Warp Shader? 1 Answer

Help with 3rd person camera 1 Answer

GUI Menu After every round how do I display a random image? 1 Answer

Zooming part of the screen without Render to texture 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