When dealing with 3D, we often have to do space change. And we often end up with this kind of code:
var pointPos = new Vector3(...)
var transform = new Matrix4x4(...)
var newPos = tranform * pointPos;
A good way to avoid bugs is to always specify in which space variable are expressed:
var posInPlayerSpace = new Vector3(...)
var playerSpaceToWorldSpace = new Matrix4x4(...)
var posInWorldSpace = playerSpaceToWorldSpace * posInPlayerSpace;
Now, spot the bug in the line below π
var posInWorldSpace = playerSpaceToWorldSpace * posInViewSpace;
Top comments (0)