unity 3d student

Beginner B18 – Local vs World Direction

How to distinguish between Local and World directions in scripting.

Code Used (Javascript)

function Update () {
  1.  //transform.Translate(Vector3(0,0,1) * Time.deltaTime);
  2.  var fwd = transform.forward * 100;
  3.  rigidbody.AddForce(fwd);
  4. }

Further Reading

Share via Social Media

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • Add to favorites


    This site is wonderful. I’m sure many people will benefit from it.
    Are we going to be making a tetris game? 😉

    • Hi et, thanks for the message – we’re not going to be making a tetris game no, but I do love it so! couldn’t resist when thinking of background patterns!

    Will, keep doing a great job!

  • I agree, this site makes learning Unity much easier. Great job with the tutorials. Looking forward to seeing more!

    Much appreciated.

  • Will, this is simply Brilliant. You are right to “chunk” the training into smaller digestible units. It’s easy to follow and take notes. I am a designer and 3d modeler. live in zBrush, but I am tired of seeing my object motionless or without a sense of purpose other than stuck in this static pose. I picked Unity iPhone and while the forums are great, I think this approach is the best.

    Please when you cover an area, can you just make sure the same applies to the Unity iPhone as well and if not, just touch on how you would do the same for the Unity iPhone. Thanks a bunch. I got your book BTW!!!

    Awesome Awesomeness!

    • Hi Andre, I’ll probably be moving on to adding info about iphone dev at some point but I don’t think its valid to cover how to do it for all platforms at this stage – mostly because unity 3.0 will be able to export to iOS, Android, Consoles, Desktop, Web.. and more, so really it will get complicated to try and cover all bases, but i’ll attempt to point out where possible if things don’t apply to mobile. Good point though thanks for the comment 🙂

    Great site! Thanks guys for the hard work. See ya.

  • Great job on these tutorials. I hope to see more soon.

  • Hi there just wanted to give you a quick heads up. The words in your article seem to be running off the screen in Firefox. I’m not sure if this is a format issue or something to do with internet browser compatibility but I thought I’d post to let you know. The layout look great though! Hope you get the problem solved soon. Cheers

  • I just started learning Unity yesterday and discovering your incredible site was like finding a gold mine! What an excellent resource you have created for the community. Thank you, thank you, thank you!

    I’ve made it through all of your essential and beginner lessons. Now I’m on the first challenge. I’ve got everything working excellent, except this one component. Basically, I don’t fully understand what direction “forward” really is? How is it determined? Is it always along a particular axis?

    I was attempting to find official documentation on “transform.forward” but couldn’t locate any. I check here:
    But it doesn’t mention forward. Where is the best place to find detailed documentation for the engine?

    Thanks again!!

    • The transform.forward should remain the forward direction of a transform – ie the forward of the Z axis an object is facing. It’s also worth reading up on transform.TransformDirection as this deals with changing coordinates that are in World coords and translating them to local coordinates. This is because there is a persistent world X,Y and Z plane, and you’re dealing with objects that have direction of their own stored locally in the transform component, does this make sense?

    Ugh, thank you for this tutorial. I’ve read and watched about this same issue on some other sites as well as this one. However, maybe I’m dumb but I just don’t get your point. Do you mean an object should use its own directions instead of world directions ? And is this the same as the two “Local” and “Global” button in the toolbar ? Ahh, so confusing T_T…

  • I dont post comments in websites, but I need to tell you how great your tutorials are. I just bought your book!!!

    • That’s very kind, thanks! enjoy your unity development!

    Alternative C# Code

    using UnityEngine;
    using System.Collections;

    public class TranslatorC : MonoBehaviour {

    public Vector3 vec=new Vector3(0,0,1);

    void Start () {


    void Update () {
    Vector3 fwd=transform.forward*50;

  • I’m in love with your tutorials man. VERY helpful and guides you in the RIGHT DIRECTION getting us on our feet coding/developing in no time. I’ve watched TONS of videos throughout youtube and somehow never ran across your videos until I hit this site. Absolutely brilliant. Thank you for your contributions, seriously. Originally came here through a link regarding GUI Basics, and decided to start from the very beginning due to the amount of knowledge I received just in the GUI section (Which I’m grasping VERY firmly now btw).

    Keep up the great work my friend.

    -DJ Fat Steve

  • Thanks for the tutorial. Helps a lot especially for beginner like myself.

    I have a question here after experimenting changing the codes (c#).

    The following code works just fine, the object moves in local direction.

    void Update () {
    Vector3 fwd = transform.forward * 100;
    GetComponent ().AddForce (fwd);}

    If i added the Time.deltaTime factor in, it ends up moving world direction. Why is that?
    Vector3 fwd = transform.forward * 100 * Time.deltaTime;
    GetComponent ().AddForce (fwd);}


Leave a Comment