Make NPC to throw projectile at player location

Hello,

How to make AI to throw grenade to player location ?
Right now i am using projectile but it has fix speed, so player can be far or near but grenade always land at fixed distance. I want to make NPC to throw at player location. HOW ?

Anyone ?

This is very simple.

Here is an example:

First, you must uncheck the “Auto Active” checkbox in the projectile movement component.

Then, in the NPC char you use “SuggestedProjectileVelocity” node, where given a speed, an origin and destination locations, it gives you the velocity vector required to reach the destination point. So:

In your NPC, just call that function after spawning the projectile.

Now, adapt this to your case.

PS: If can’t reach target, then the velocity returned by SuggestedProjectileVelocity is (0,0,0).

1 Like

Thanks EvilCleric,

I had no idea that such node exist, I’ll give it a try.

1 Like