What is the meaning of Vector3.back?
Answer by Kleptomaniac
Apr 05, 2012 at 02:51 AM
There is no such command. Try instead -Vector3.forward. ;)
It's not mentioned in the script reference, but this does compile and run for me in Unity 3.5.0f5:
//output is "(0.0, 0.0, -1.0)"
Shame the reference isn't more up to date, really. =\ It's only as useful as it is authoritative, IMO.
Actually it's deprecated. It was in Unity in the 1.x days. Obviously it's still technically in Unity, but not officially. Best not to use it. (Surprised it still works though.)
Wow, thanks for that! Just tested and Vector3.back is indeed the same as -Vector3.forward ... also tested with Vector3.left ... same as -Vector3.right. I would never have known ...
Answer by rutter
Apr 05, 2012 at 03:07 AM
Vector3.forward gives you a unit vector pointing along the z axis, or (0,0,1).
Vector3.back gives you the opposite, (0,0,-1).
Neither of these are necessarily useful on their own, but they can be very useful in tandem with other code.
Some simple examples:
//pos points 1,000 units down the z axis
pos = Vector3.forward * 1000f;
//bar equals foo with zeroed x and y components
bar = Vector3.Scale(foo, Vector3.forward);
//baz points down the z axis with length equal to foo's
baz = Vector3.forward * foo.magnitude;
Those examples don't necessarily make sense out of context, unfortunately. The more you know about vector math, the more apparent the utility of these values should be.
Remember that vectors express a direction and length. A unit vector, with length one, can be thought of as expressing a pure direction. That's very useful in game development.
Answer by kolban
Apr 05, 2012 at 07:46 AM
It is shorthand for writing Vector3(0,0,-1)
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
5 People are following this question.
Make an FPS gun point at the mouse position.
Orbit Sim without Physics Engine
Waypoint System Does Not Rotate Enemy?
Resize object forward instead of along the z axis
Store startposition in a variable