Setting a pawn in the VRCamera so that a turret can shoot it

Hey, real quick, how do I set a pawn near or inside my VRCamera so my turret can target and shoot at it. I’ve been trying for 30 minutes and I can’t seem to find out how.

Confused by your question. The VRCamera is a component of your Pawn, so you don’t set a Pawn “inside” a VRCamera, exactly the opposite. Can you try to describe it with different words maybe?

I’ll try to. So basically instead of a turret shooting at my feet, I want it to shoot at my head. I have a sphere around my camera so you can see a shadow, but since that is in my player’s pawn, when I try to set it up to aim at something, it aims at player as a whole, not my head. Is there a way I can get a pawn, actor, anything that can be targeted by the cast to command and make it stay there so the turret can shoot at my head?

Sorry, but what do you mean about get the head sphere component. I feel so dumb asking this. (It’s only my 4th day of using UE4 and my third day making a VR game. I’m sure everyone knows what you mean but me xd.)

Well since my blueprint is way to long to post, let me sum it up.

On See Pawn goes to Cast to (insert object). It goes through a sequence node through Then 0 which goes to SetActorRotation. New rotation Find Look at Rotation, GetActorLocation self, GetActorLocation which is plugged into As Actorlocation on the cast to. Then 1 goes to a branch, and true goes to LineTraceForObjects, On hit, Break Hit Result. The normal white node goes to something I have to create a decal and particle effect, nothing really there rather than that. LineTrace start goes to GetWorldLocation of TurretGun then that goes into Get Forward Vector which goes into Vector*Float. The green thing is set to 9999 and the right side of it goes into Vector Addition, the left top of that goes into the GetWorldLocation and the right side goes into LineTrace End.

I cannot thank you enough!

OK but then the problem is with the turret code. Probably it is getting the Actor Location of your pawn while you want it to get the location of the sphere component around the head. In this case you can still cast to the VRPawn, get the head sphere component from it and only then call Get World Location.

Don’t worry, we all started in the same way. Your turret is very likely trying to find your Pawn with a raycast (Line Trace by Channel) or similar. When it has found it, it needs its location to shoot at it. Right now it is probably getting its Actor Location, which means the location of its root component. If you want the turret to shoot at the head, the turret has to aim at the location of the sphere component instead that the root component. So the turret needs to get the world location of the sphere component which is around the head. If the turret casts to VRPawn, you can drag out of it and do Get Sphere (provided the name of the sphere is Sphere) and then Get World Location. This is where the turret needs to aim at.

If you want me to be more precise you need to post some of your Blueprints, otherwise it will just be a bunch of educated guesses.

Do you see where it casts Pawn to actorlocation and then uses GetActorLocation to feed the Target pin of the Find Look At Rotation? Drag out of the As actorlocation pin of the cast, right click and search for Get Sphere (which is the sphere around your head, not sure how you called it) and then feed the output of Get Sphere into GetActorLocation, then to the Target pin of Find Look at Rotation.

If it works, can you be so kind and accept my answer? Thanks!