# MiniB3D up, forward and right

#### SLotman

##### Active member
3rd Party Module Dev
As I was watching some math tutorials for gamedev, one concept always mentioned are those 3 vectors that are extracted from every GameObject: the up, right and forward vectors, which as their names indicate, are vectors pointing (in local space) up, right and forward. Engines like Unity and Unreal provides this out of the box for every object in the engine.

This can be easily achieved on MiniB3D, just add those lines below "public" on TEntity:

Code:
``````    Method Up:Vector()
Return New Vector(mat.grid[1][0], mat.grid[1][1], mat.grid[1][2])
End Method

Method Right:Vector()
Return New Vector(mat.grid[0][0], mat.grid[0][1], mat.grid[0][2])
End Method

Method Forward:Vector()
Return New Vector(mat.grid[2][0], mat.grid[2][1], mat.grid[2][2])
End Method``````

And that's it!

But... why, you ask? Well, this is useful to test, for example, if two entities can see each other. Take their forward vectors, normalize them and calc the dot product. Result closer to -1 they're facing each other. Closer to 1 they're facing the same direction. Results closer to 0, they're looking at perpendicular directions.

This is just one example. You could use the forward, up or right vectors to move the entity forwards, upwards or sideways (just like MoveEntity).

Anyway, after adding those lines, you can just call any entity (even pivots) with .Up(), .Right() or .Forward() to get those vectors.