SuggestProjectileVelocity not working like in the video


Has anyone else received an error when trying to use this as the first argument in SuggestProjectileVelocity?

if (UGameplayStatics::SuggestProjectileVelocity(this, LaunchVelocity, ChopperGunBarrel->GetComponentLocation(), TargetLocation, LaunchSpeed))
			UE_LOG(LogTemp, Warning, TEXT("Aim Direction: %s"), *LaunchVelocity.ToString());
			UE_LOG(LogTemp, Warning, TEXT("Can't AIM!"));

Reults in this error:

ActorComponent_ChopperAiming.cpp(49) : error C2664: 'bool UGameplayStatics::SuggestProjectileVelocity(UObject *,FVector &,FVector,FVector,float,bool,float,float,ESuggestProjVelocityTraceOption::Type,const FCollisionResponseParams &,const
 TArray<AActor *,FDefaultAllocator> &,bool)': cannot convert argument 1 from 'const UActorComponent_ChopperAiming *const ' to 'UObject *'

My aiming component is an ActorComponent, just like Ben’s…


FYI, I can send the parameter my ChopperGunBarrel component and everything’s peachy. My gun-barrel is a UStaticMeshComponent made from a primitive cylinder.

But I’d still like any help that you all can provide as to why my relatively identical code doesn’t seem to work.

(For what it’s worth, I’m running 4.12)


Hi Bryant,

Can you try changing ChopperGunBarrel->GetComponentLocation() to ChopperGunBarrel->GetSocketLocation(FName(“Projectile”)) although I don’t think that’ll be causing the issue, just that the projectile might release from the wrong location in the barrel.

I wonder if you might be something off on the declaration. Could you share up your code on GitHub and I’ll see if I can suss what’s going on.




It’s already been solved, his function was const, so this was const and since the paramater takes a non-const object it wouldn’t work.


Shoot! Forgot that I posted this here, too.

Mezz, Dan is correct–I had AimAt() set to a const function originally.

Thank you for the help!