So I have a raycast from my projectile. I’m trying to get the raycast to applyimpulse to any rigidbody it hits.
This is in my main file.
PhysicsWorld* physicsWorld_ = scene_->GetComponent<PhysicsWorld>();
PhysicsRaycastResult result;
Vector3 pos(boxNode->GetWorldPosition());
Ray ray(pos, boxNode->GetWorldDirection()); // the given vector is the direction
physicsWorld_->RaycastSingle(result, ray, 40.0f, 0);
if (result.distance_ <= 40)
{
projectile->impact(result, ray);
}
This is in my projectile class.
void impact(PhysicsRaycastResult result, Ray ray)
{
RigidBody* resultBody{ result.body_ };
if (resultBody)
{
Node* resultNode{ resultBody->GetNode() };
resultBody->ApplyForce(Vector3(5.0f,5.0f,5.0f),
resultNode->WorldToLocal(result.position_));
URHO3D_LOGDEBUG("FIRED");
}
}
@Modanung helped me with some of the snippet. I see that the event does trigger in the console, but nothing happens to any rigidbody that the projectile hits.