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);
}
@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.
I think the force might be a little low. Try it with ApplyImpulse instead of ApplyForce and ray.direction_ * 9000.0f instead of the “Vector3::ONE * 5.0f”.
ApplyForce is meant to be used during the FixedUpdate event, together with a timestep.
What I got it working now. I believe the problem was two things. One like @Modanung said the Impulse may have been a small amount. Also I went to check the collision layers and it was suppose to be one not two.