Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.18
more ▼

asked Dec 09 '17 at 09:42 PM in VR

avatar image

3 1 2

avatar image vr_marco Dec 09 '17 at 09:54 PM

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?

avatar image McLyntree Dec 09 '17 at 10:03 PM

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?

avatar image vr_marco Dec 09 '17 at 10:14 PM

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.

avatar image McLyntree Dec 09 '17 at 10:20 PM

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.)

avatar image vr_marco Dec 09 '17 at 10:25 PM

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.

avatar image vr_marco Dec 09 '17 at 10:26 PM

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.

avatar image McLyntree Dec 09 '17 at 10:43 PM

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.

avatar image McLyntree Dec 09 '17 at 10:44 PM

alt text

basicallythis.jpg (67.4 kB)
avatar image vr_marco Dec 09 '17 at 10:50 PM

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.

avatar image McLyntree Dec 09 '17 at 10:58 PM

I cannot thank you enough!

avatar image vr_marco Dec 09 '17 at 11:16 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

alt text

more ▼

answered Dec 09 '17 at 10:54 PM

avatar image

2.2k 10 6 12

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question