One of my objects is supposed to look at another object, but when I perform collision detection, it seems to disregard the rotation applied using LookAt
. Instead, it defaults back to its original rotation. Why isn't it taking into account the rotation applied with LookAt
?
Take a look at this comparison:
https://i.sstatic.net/fhD2P.png
The blue object represents the default orientation, while the green one illustrates the blue object after applying LookAt
.
Why isn't the collision detection affected by the changes made using LookAt?
The collision detection function I am using for my RTS game (which only considers X and Z coordinates) is as follows:
function collisionXZ(o1, o2) {
if (Math.abs(o1.position.x - o2.position.x) > (o1.geometry.parameters.width + o2.geometry.parameters.width) / 2)
return false;
if (Math.abs(o1.position.z - o2.position.z) > (o1.geometry.parameters.depth + o2.geometry.parameters.depth) / 2)
return false;
return true;
}