So I have a method that is suppose to constantly cast a ray directly in front of my character to check if an enemy is within range. The trouble I have is the the raycast does not follow the characters rotation. I must disclose that I am trash with the physics part of the API. Some of the values below are just me testing my issue.
void EnergySword::MeleeLunge(StringHash eventType, VariantMap& eventData)
{
PhysicsWorld* physicsWorld_ = scene_->GetComponent<PhysicsWorld>();
PhysicsRaycastResult result;
Vector3 charPos = node_->GetWorldPosition();
Quaternion rot = node_->GetWorldRotation();
Quaternion dir = rot * Quaternion(45.0f, Vector3::FORWARD);
Vector3 rayDir = dir * Vector3::FORWARD;
Vector3 aimPoint = node_->GetWorldDirection() + rot * Vector3(0, 1.7f, 0);
Ray ray(charPos, rayDir);
physicsWorld_->RaycastSingle(result, ray, 8.0f, 1);
if (result.body_)
{
debug->AddLine(charPos, aimPoint, Color::CYAN, false);
}
}