Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7714363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:06:32+00:00 2026-06-01T02:06:32+00:00

I’ve followed 3DBuzz’s XNA AI tutorial and it uses vectors to calculate object directions.

  • 0

I’ve followed 3DBuzz’s XNA AI tutorial and it uses vectors to calculate object directions. I’m having trouble understand a simple piece of code that moves an object in a given direction (The 3DBuzz videos don’t really dig deep into the vector math).

A bit of background

The AI system uses Actor classes which you can assign Behaviors. Behaviors have a set weight property defining how much of the behavior is taken into account when working with multiple behaviors. Below is a behavior for moving an object in a constant direction. This is the update method, being continuously called.

 public override void Update(Actor actor)
 {
     actor.Direction += this.direction * this.Weight;
 }

The thing I don’t understand is, why does my object move in a constant direction while the Actor’s Direction variable is incremented with that direction each frame?

Initially I thought it was because the Direction vector is normalized on each update in the Actor class, but when logging my direction before and after the normalization, they’re both different. This is my output (Trace.WriteLine):

DIR: {X:0.7071068 Y:0.7071068}
NOR: {X:0.7071068 Y:0.7071068}
DIR: {X:2 Y:2.537759E-27}
NOR: {X:1 Y:1.268879E-27}
DIR: {X:0.7071068 Y:0.7071068}
NOR: {X:0.7071068 Y:0.7071068}
DIR: {X:2 Y:1.268879E-27}
NOR: {X:1 Y:6.344397E-28}
DIR: {X:0.7071068 Y:0.7071068}
NOR: {X:0.7071068 Y:0.7071068}
DIR: {X:2 Y:6.344397E-28}
NOR: {X:1 Y:3.172199E-28}
DIR: {X:0.7071068 Y:0.7071068}
NOR: {X:0.7071068 Y:0.7071068}
DIR: {X:2 Y:3.172199E-28}
NOR: {X:1 Y:1.586099E-28}
DIR: {X:0.7071068 Y:0.7071068}
NOR: {X:0.7071068 Y:0.7071068}
DIR: {X:2 Y:1.586099E-28}
NOR: {X:1 Y:7.930497E-29}
DIR: {X:0.7071068 Y:0.7071068}
NOR: {X:0.7071068 Y:0.7071068}

And the code to get this output (in Actor.cs):

        Trace.WriteLine("DIR: " + this.Direction);

        if (this.Direction.Length() > 0f)
            this.Direction.Normalize();

        Trace.WriteLine("NOR: " + this.Direction);

        if(IsMoving)
            this.Position += this.Direction * this.Speed;

I don’t understand why I’m moving in the same direction while my Direction vector is different each time. Can anyone explain this to me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:06:33+00:00Added an answer on June 1, 2026 at 2:06 am

    enter image description here

    As you can see, you are adding vectors and normalizing, and you are aproximating to the vector you are adding…. here the effect is magnified by the module of the behaviour vector direction… with a smaller vector it will takes more cycles to aproximate it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
i got an object with contents of html markup in it, for example: string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.