Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 bracciata · Aug 11, 2015 at 11:11 PM · c#transformforwardexplain

I want a better explination than the one in unitys tutorial

So I'm using the scripting method transform.forward with a transform and I'm trying to figure out how it works. Unity explains it as "The blue axis of the transform in world space.". Can somebody explain what this means. I'm using it for a 2d platforming shooter and I'm using a gameobject called gun end attached to the end of the gun and it turns left and right would this work for me to add force in the direction I want. Although main thing is just explaining using transform.forward please help.

Comment
Add comment · Show 1
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 Hexer · Aug 11, 2015 at 11:17 PM 1
Share

You know that thing in the scene view that has those red/yellow ,green and blue arrows? Those arrows stand for the x.y.z postition of your object.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Vice_Versa · Aug 11, 2015 at 11:48 PM

x(red arrow) goes sideways, y(green arrow) goes up and down, z(blue arrow) goes forward and backward. As for the "transform.forward" method, transform means an objects location, rotation, and scale. Transform refers to all of those but is also sort of another way to reference a gameObject. transform.forward means get the forward direction (z axis) of your transform(gameobject). if your making a 2d platformer game, im assuming transform.right is probably what you want to use

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
avatar image
1

Answer by Eno-Khaon · Aug 12, 2015 at 12:29 AM

When working with these directions and orientations, there are two aspects to keep in mind: Global and Local orientations.

When talking about an object's Global (or "World") position or rotation or scale alike, that is the final, resulting orientation of an object. As far as position (or "translation") is concerned, as has been described, the three-dimensional status is represented with a horizontal red arrow (X-axis), a vertical green arrow (Y-axis), and a horizontal blue arrow crossing them (Z-axis).

The Z-axis is considered to be pointing "forward", therefore the X-axis points to the right and the Y-axis points up. These correspond with Vector3.forward, Vector3.right, and Vector3.up respectively.

Now, this is DIFFERENT than transform.forward, right, and up.

An object's local orientations are very important, especially when you have multiple objects with a parent/child relationship. This is what you see when you drag an object onto another in your hierarchy window in Unity.

Let's say you have an object which you shrink down to 1/100 of its normal size, so it's ridiculously tiny. Then, you make another one its child. That child will appear to be normal size relative to the world. However, it will actually be 100 times enlarged, because that is the object's relative scale to its parent.

Now, in this case, there's NOT a parent/child relationship, so why does the local rotation matter? Well, it's actually very simple. Face North. Then, turn to your right. Now, you're facing East. Either way, you're looking forward, but to the world, North won't change.

The same holds true for global and local rotation. You can think of the global Z-axis as a line running north and south. This represents north as "Vector3.forward". However, the direction anyone or anything is facing is their own. This is represented by "transform.forward" instead.

You mention you're working on a 2D game, which really doesn't change very much. The X-axis runs from left to right. The Y-axis runs from bottom to top. However, without depth, there is no Z-axis to worry about. Instead, if your character naturally faces to the right (in other words, your character faces right with 0-degrees of rotation applied), then transform.right will act as your character's relative "forward" direction. If the game is, instead, a vertical shooter or a top-down racing game, those often have a character facing upwards by default. It's just a matter of knowing where to start.

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

27 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

transform.forward makes my GameObject Disappear 0 Answers

C# always move an object forward and still use physics 1 Answer

How to combine movements of the transform.rotation and transform.position 1 Answer

Double reference to waypoints in FSM 0 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