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
1
Question by Absyss · Feb 19, 2010 at 09:36 AM · movementphysicsrigidbodyaccelerationinertia

How to Tilt a Spaceship Based on Inertia/Acceleration Force Separate from Facing Direction?

Situation:

  • the game is a dop down perspektive ( bird view )
  • i have a PlayerObject (Spaceship) that always faces the Mouse ( transform.rotation.y )
  • and a up/down/left/right movement ( rigidbody.velocity.z & x )
  • inertia is visualized with X/Y Rotation ( transform.rotation.x & z )

What i need:

  • i dont want the tilting (inertia) in the looking direction BUT in the movement direction

I think a good example is a Hoverboat that can slide sidewards but inertia forces apply still in movement direction ...

here is a shematic: http://i238.photobucket.com/albums/ff160/absyss/_Q_RotateMove.gif

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
1
Best Answer

Answer by runevision · Feb 19, 2010 at 10:16 AM

Maybe you can use this:

// Rotation to face the mouse. // (Calculation of yRotationToFaceMouse is not covered here.) Quaternion rot = Quaternion.Euler(0, yRotationToFaceMouse, 0);

// Find the axis we want to tilt around. // It should be perpendicular to the velocity and to the up direction. Vector3 tiltAxis = Vector3.Cross(Vector3.up, rigidbody.velocity);

// Now rotate the existing rotation by tiltAmount around tiltAxis. // (Calculation of tiltAmount is not covered here.) rot = Quaternion.AngleAxis(tiltAmount, tiltAxis) * rot;

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 Absyss · Feb 19, 2010 at 12:25 PM 0
Share

that works perfectly thanks! Just a typo to correct: "Vector3.Cross"

avatar image
2

Answer by Statement · Feb 19, 2010 at 09:54 AM

Try separating the problem into two distinct scripts.

  1. Place the object you want to tilt in a game object and call it "Ship".
  2. Place "Ship" in a parent game object and call it "Ship Facing Camera".
  3. Place tilt rotation in a script attached to "Ship" and make them use local transform.
  4. Place movement and facing camera rotation in a script attached to "Ship Facing Camera".

That way you get the benefits of having two separate transforms to work with, essentially reducing the maths needed to calculate tilt. Now you can apply tilt with local coordinates, and don't have to worry about any other rotations because parents do that for you.

Comment
Add comment · Show 2 · 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 Absyss · Feb 19, 2010 at 12:28 PM 0
Share

yes i have thought of this solution before but i wanted to combine both rotations into one calculation.

avatar image Absyss · Feb 19, 2010 at 12:28 PM 0
Share

PS: i might use this for other puposes though

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

No one has followed this question yet.

Related Questions

RigidBody immediately stops after AddForce 1 Answer

Collisions causing Rigidbody to go Haywire and move randomly. 1 Answer

Issues Making Character Move With Rigidbody 1 Answer

Ground clamping a rigidbody on slope 1 Answer

Interpolate problem? Jump isn't smooth... 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