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 Mïglu · Nov 02, 2012 at 08:31 PM · raycastvelocityhovertransformdirection

Spherical velocity conservation

I am trying to create an object that accelerates around a sphere. In the object's update function, I apply a force to it that it parallel to its forward. I also have this code to keep the object at a constant distance from the sphere and parallel to the sphere's surface. However, no acceleration occurs because the velocity is not conserved in spherical coordinates. To fix this I tried adding the commented lines, which are supposed to first store the current local velocity, and after the position and rotation change, set it again to the previous value. However, it only produces extreme jerkiness. What is the best method?

     var hit : RaycastHit;
     var newForward : Vector3;
     if (surfaceCol.Raycast(new Ray(thisTransform.position, surface.position - thisTransform.position), hit, 100)) {
         newForward = Vector3.Cross(hit.normal, thisTransform.right);
         
         //    var oldVel = thisTransform.InverseTransformDirection(thisBody.velocity);
         
         thisTransform.LookAt(thisTransform.position + newForward * 50, hit.normal);
         thisTransform.position = hit.point + hit.normal * height;
         
         //  thisBody.velocity = thisTransform.TransformDirection(oldVel);
     }
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 MountDoomTeam · Nov 02, 2012 at 09:08 PM

do you want to do it with physics or with just movement formula?

with physics you could have 2 constant forces that apply pressure to it towarde the centre and away from the centre of the orbital sphere depending on its distance to the orbital sphere, and apply a constant force forwards and a lookat centre+90degrees. in this way you use physics to keep it in the sphere instead of using some special position formulas that cancel the physics. also it makes real orbital physical forces that you can tweak the strength of an have lots of different effects, and if you knock a thing from its orbit it moves back there physically, i did that to simulate electrons it looks great.

if you dont need physics just use sine and cosine to make sphere and make them multiply with time.time inside the cosine and sine like x=sine(time.time*time.time(accellerates exponentially) and y is with cos.

does it have a disc orbit, a spirograph orbit, or other?

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 Mïglu · Nov 04, 2012 at 03:48 PM 0
Share

The orbit is arbitrary. The requirements are that the object can accelerate and that the distance to the sphere's center is constant. I want to use a physical method but using the method that you suggested would not fill the second requirement.

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

11 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

Related Questions

Predicting the path of a ball from it's forward vect 2 Answers

Aligning player to surface 2 Answers

How to detect UI Elements with Raycast 1 Answer

Hover Effect with more rays as turbines? 1 Answer

know when GVR raycaster is looking at nothing 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