Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

enter image description here So I found this steering behaviour code in a book but i dont really understand the last part of the code what exactly is he doing because im unfamiliar with c++. Why would you need to PointToWorldSpace, why not just apply to the object velocity ?

//move the target into a position WanderDist in front of the agent
SVector2D targetLocal = m_vWanderTarget + SVector2D(m_dWanderDistance, 0);
//project the target into world space
SVector2D targetWorld = PointToWorldSpace(targetLocal,
//and steer toward it
return targetWorld - m_pVehicle->Pos();
share|improve this question
I assume those are all vectors right? The point to worldspace is probably translating it from a local to global space. –  Sidar May 14 '13 at 9:56
yes those are vectors but, what do you mean by local –  Matthew May 14 '13 at 10:18
I might be off here. I'm just going by the assumption of the function name. A local space is basically a unique cartesian coordinate space which effects how your sprite is transformed/translated. The x and y(position) of your sprite/entity is the center 0,0. So you basically move this space around, stretch or squeeze it (scaling),shear, and rotate it. Your global space is probably where all your entities live in. And you sometimes need to translate between the two spaces to get the relative point in space. Sorry If im not clear on this, I suggest googling about the concept. –  Sidar May 14 '13 at 10:35
This question appears to be off-topic because it is asking for help understanding code without demonstrating sufficient understanding of the problem scope or context. –  Josh Petrie Dec 3 '13 at 5:14
add comment

closed as off-topic by Josh Petrie Dec 3 '13 at 5:14

  • This question does not appear to be about game development within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.