Convert Actor location to FHitResult?

Hello.

The title tells everything. I have an Actor and I want to construct a FHitResult variable using that Actor’s location.

How can I do it?


EDIT:

I’m in a weird situation. I have a Projectile class where you have to specify whether the projectile is an explosive or not (bExplosive). The difference between a normal projectile and an explosive one, is that the Explosive, after a certain ammount of time Explodes, which means that applies damage after a time even if it doesn’t hit anyone (best example: grenade; a grenade explodes after a time, even if no player is directly hit).

The problem is that I have an Explode() function taking a FHitResult as parameter. With that hitresult, it applies a GameplayStatics::ApplyRadialDamage() and then spawns the Explosion FX.

I have set a timer in the BeginPlay() of the class which calls a specific function when the time comes. The purpose of that timer is to determine when the lifetime of the object is over, so it can call the Explode() function.

Here is the issue: in the timer I call the Explode() function, but which FHitResult do I pass to it? I’m forced to pass it something!

If you need the code, i’ll upload the class’ .cpp so you can see better the situation.

FHitResult is just struct so you just make it and fill it with data. You can also eaily use this constructor:

Look up API refrence too:

Thanks, the constructor you sent me in the first link looks for 2 vectors (Start and End). I can’t understand which parameters I should pass to it. My vector is one, and representes the position of the Actor.

FHitResult is just a struct holding information that comes from Physics. There is no Point filling the Information manually unless you want todo Fake HitResults for some reasson. In that case use this Constructor FHitResult::FHitResult | Unreal Engine Documentation

Otherwise think about why you doing it at all. There are only a few exotic cases where you would do that :stuck_out_tongue_winking_eye:

Good Luck and have Fun.

I’m in a weird situation. I have a Projectile class where you have to specify whether the projectile is an explosive or not (bExplosive). The difference between a normal projectile and an explosive one, is that the Explosive, after a certain ammount of time Explodes, which means that applies damage after a time even if it doesn’t hit anyone (best example: grenade; a grenade explodes after a time, even if no player is directly hit).

The problem is that I have an Explode() function taking a FHitResult as parameter. With that hitresult, it applies a GameplayStatics::ApplyRadialDamage() and then spawns the Explosion FX.

I have set a timer in the BeginPlay() of the class which calls a specific function when the time comes. The purpose of that timer is to determine when the lifetime of the object is over, so it can call the Explode() function.

Here is the issue: in the timer I call the Explode() function, but which FHitResult do I pass to it? I’m forced to pass it something!

If you need the code, i’ll upload the class’ .cpp so you can see better the situation.