• 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 George_1999 · Mar 30, 2015 at 09:40 AM · rotationquaternioncombinesteeringalign

Two scripts rotating the same object

I have a car with two scripts attached to it , one scripts handles the steering while the other one rotates it to the ground normal vector , when i try to steer it though the car does align itself with the ground but it's steering remains still . Here's the steering script :

 if(Input.GetKey(KeyCode.D))
             {
                 this.transform.Rotate (Vector3.up*Time.deltaTime*steerAmount);
             }
             if(Input.GetKey(KeyCode.A))
             {
                 this.transform.Rotate (-Vector3.up*Time.deltaTime*steerAmount);
             }

And there is the aligning script :

         if(Physics.Raycast(this.transform.position,-this.transform.up,out hit,2034.0f))
         {
             this.transform.up = Vector3.Slerp(this.transform.up,hit.normal,Time.deltaTime);
         }


Now i know i have to find a way to combine these two rotations but i can't find one yet . Thanks for your time :)

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 Safforn · Mar 30, 2015 at 09:42 AM

Try putting one of these in a LateUpdate() function.

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 George_1999 · Mar 30, 2015 at 10:01 AM 0
Share

Tried it . didn't work . it rotates a little bit and then snaps back (as i expected it to)

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

how to combine 2 quaternion components? 2 Answers

Combining two Quaternion Slerps on an object 1 Answer

How to smoothly align an object to a surface, but only partially 2 Answers

combine / convert rotations (Quaternion and Vector3) 1 Answer

LookRotation Vector3 is Zero, Yet Slerp Still Rotates? 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges