Inacurrate aoa readings

console.log(this.calculateAoa(this.entity, this.entity) * (180 / Math.PI));
LiftGen.prototype.calculateAoa = function(entity, surface) {
    var velocityDir = entity.rigidbody.linearVelocity;
    var forward = surface.forward;
    var dotProduct = velocityDir.dot(forward);
    var angleOfAttack = Math.acos(dotProduct)
    return angleOfAttack;
};

I have zero clue as to why this gives inaccurate responses, so any help would be greatly appreciated.

So it looks like you forgot to normalize the linear velocity before taking the dot product to the forward vector. This does some weird stuff when trying to do what your doing here. making line 3

var velocityDir = entity.rigidbody.linearVelocity.normalize();

should solve your problem.

1 Like