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 Flamin_Jesus · Jun 04, 2011 at 01:38 AM · forward

transform.forward not updating?

OK, this is patently weird (to me, anyway)

So I've been trying to get the degree on a single local axis between two points for a while now, and that, in and of itself works fine. However, I also need to compare this angle to another angle, and now I've noticed something odd: As far as I understood, the transform.forward parameter should always hold the global direction the object is facing, however, for me it only seems to update if I manually assign the forward Vector in a script (It also correctly displays the changed, new rotation in the editor and game view). If I simply change the rotation either from within a script or by using the direct editor controls, the forward Vector's value doesn't update. This is true both for main GOs as well as their individual children.

I thought that transform.forward was effectively identical with transform.TransformDirection(Vector.forward) (Which doesn't do anything for me either), is this incorrect?

BTW, I'm using the most current version of Unity (Non-Pro)

Any help will be greatly appreciated.

Comment
Add comment · Show 8
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 Jesse Anders · Jun 04, 2011 at 01:52 AM 2
Share

I don't have an answer, other than to say I think it's pretty unlikely that there's a bug in the Transform.forward property. As such, my guess would be that the problem is elsewhere (e.g. you're not querying the data from the right game object, or are querying the data at the wrong time, or something of that sort).

avatar image Flamin_Jesus · Jun 04, 2011 at 02:00 AM 0
Share

Well, I found it unlikely too, but here's what I used to test different objects (Without any other scripts attached):

using UnityEngine; using System.Collections;

public class DirectionTestScript : $$anonymous$$onoBehaviour {

 // Update is called once per frame
 void Update () {
     Debug.Log("direction: " + transform.forward );
 }

}

result: 0,0,-1 stopping the game, changing the rotation in the editor window by 180 degrees: 0,0,-1 rotating the object at runtim in the editor window randomly: 0,0,-1

I don't know what's wrong, the rotation is actually correctly displayed in game.

Edit: Tried the other rotations via editor too, btw...

avatar image Jesse Anders · Jun 04, 2011 at 02:04 AM 0
Share

Do you have 'collapse' turned on in the console by any chance? (I'm not sure if that would have any bearing here, but it's often mentioned when people aren't getting the debug output they expect :)

avatar image sneftel · Jun 04, 2011 at 02:04 AM 0
Share

Out of curiosity, is the same true of transform.right?

avatar image Flamin_Jesus · Jun 04, 2011 at 02:15 AM 0
Share

Jesse: Nope, only clear on play is toggled

Ben: Same problem, it's showing me -1,0,0

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Peter G · Jun 04, 2011 at 01:57 AM

I have never had any problems with transform.forward. Not to say that you haven't discovered a bug, but I'm skeptical. How are you checking the value of transform.forward? There are lots of ways that you can test the values of it, the easiest would just be to

  Debug.Log(transform.forward);

in an Update() and see what you get.

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 Flamin_Jesus · Jun 04, 2011 at 02:12 AM 0
Share

Heh, see above, that's what I already did ;)

avatar image
0

Answer by andrew_johnson_cubic · Sep 15, 2016 at 01:34 PM

I think I had the exact same issue. It started after I crashed the editor.

Toggling enable on the affected script in the editor during run-time would make transform.forward report the correct value again.

I solved my problem by copying the whole script (Ctrl-A so I didn't miss anything) into a new file with a different name.

Conjecture Warning --> Does Unity have meta-data of script files? That might explain it.

(I know I'm 5 years late, this is for any future forum miners and time travellers that have this issue)

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 nasoukikos · Oct 31, 2016 at 10:58 PM 0
Share

$$anonymous$$an you saved me, I've been banging my head against the wall for the past couple of hours. It appears that unity can corrupt this relatively easily.

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how to move player forward relative to camera forward with "mouse-y" input 1 Answer

move box forward 1 Answer

Problems with Vector3.angle and angle to target 1 Answer

Make a object instantaite 25 units in front 2 Answers

2D Shooter - shooting forward at the current rotation 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