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
0
Question by skylerkingdev · Jun 28, 2014 at 06:30 PM · transformworld space

Object only rotates in local space

I am trying to get an object to rotate on the Y axis in world space. The issue seems to be that the object rotates fine (maybe on its local axis), but the global rotation is unchanged. Can someone point out where I am going wrong here?

 function Update () {
 
         if (inputLeft) {
 
               transform.Rotate(Vector3.up, -rotateSpeed * Time.deltaTime, Space.World);
     
         }
 
 }

The code above gives me this :

alt text

rotationproblem.png (339.5 kB)
Comment
Add comment · Show 2
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 AlucardJay · Jun 28, 2014 at 07:01 PM 0
Share

Do you have the Gizmo set to Local in the toolbar?

alt text

http://docs.unity3d.com/$$anonymous$$anual/Toolbar.html

avatar image skylerkingdev · Jun 28, 2014 at 10:10 PM 0
Share

I get the same result regardless here, thanks though.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Juice-Tin · Jun 28, 2014 at 06:51 PM

You may confused.

For a car you would want a local rotation, this way it stays forward facing.

Either that, or the script is perhaps on a child object of the car when it should be on the top-most object?

It's hard to tell really, but I would say experiment with using localRotation, or just omitting that Space.World.

Comment
Add comment · Show 8 · 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 Lo0NuhtiK · Jun 28, 2014 at 06:55 PM 0
Share

Also have a look at Wheel Colliders if you want more realistic car movement/control.

avatar image skylerkingdev · Jun 28, 2014 at 07:24 PM 0
Share

Thanks, Juice-Tin. You are right. I want the car to stay forward facing. The issue I am having is the car is rotating, but I can't use transform.forward because it is referring to the world direction.

avatar image Juice-Tin · Jun 28, 2014 at 07:38 PM 0
Share

r6834, I'm rather new to Unity as well, but just looked back on my game that uses similar code for the Camera. $$anonymous$$y camera's arrows in the editor stay facing the same direction as yours does, however it uses .forward just fine.

Have you tried using forward while adjusting your code? Or have you just been stuck on getting the editor arrows to adjust with the car? (Since forward works on $$anonymous$$e, but arrows stay the same).

Also, try using local rotation if you haven't yet.

avatar image skylerkingdev · Jun 28, 2014 at 10:07 PM 0
Share

Tried it, all I am simply trying to do is rotate the vehicle with the script above, then add a forward force to the Rigidbody. But, it refuses to move in any direction but the global directions.

 rigidbody.AddForce (transform.forward * inputVertical);
avatar image iwaldrop · Jun 30, 2014 at 01:57 AM 0
Share

Are these scripts on the same transform, or is the car childed to a parent?

Show more comments
avatar image
0

Answer by Bunny83 · Jun 30, 2014 at 03:10 AM

There are only two possible reasons why your gizmos keep the world space direction:

  • Because like alucardj said you have set the gizmos to global instead of local. However that won't influence transform.forward

  • This script is attached to a child object (which is rotating) but you have selected the parent object which of course isn't rotated.

Make sure your controlling scripts (rotation / movement) are attached to the top most object and not to some child object.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Image coordinate and Z buff to World Space Position 1 Answer

Objects with same position appear in different places 2 Answers

Physics in Local Space rather than World Space 2 Answers

Convert Unity position to Maya position 1 Answer

Rotate and transform in local space 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