VR headset Pawn/AI Tracking

Hey All,

need your help! I am working with SteamVr/Vive, and currently have an AI that does a Simple Move to Player Pawn when spawned, and once it is close enough, it begins its attack list. The problem I am having is that the ‘Player Pawn’ doesn’t seem to stay with the Headset/HMD… so the AI just attacks the pawn object where it was placed at level start, which means you can walk around the AI and he is still attacking that pawn spawn location/not following the HMD as it moves around. I also setup a Rotator on an event tick for the AI, so that it always faces the player pawn, and have verified that, THAT works…but again the pawn/HMD seem to not be attached to each other.

Am I missing something? I have the Player camera ‘locked’ to the HMD, so that part is setup correctly.

Thanks!

I figured out a simple/neat way to make this work if anyone is interested!

What was your way of making it work?

You need the camera location/actual HMD position instead of pawn location. You would also want a collision object attached to the camera that can interact with the AI.

How can you let the ai faces the player pawn? thanks!

There is ‘rotate to face blackboard entry’ task in a behaviour tree.

Om,Can you give me some function to do that? I am new,and can not canculate it !

How did you make the location of the camera/headset public. At current my ai tracks the default vr pawn asset which results in it always looking for the center of the “scene” which in this case is “VROrigin”. I was also thinking that tracking the headset would be better, but the ai is searching for a pawn.

For working with EQS or AI, sometimes it is easier to make dummy blueprint actor, and tell AI to follow it instead of real goal. Then that actor can snap to real actor location (usually update on tick and just copy transform over and apply to self). This way i can have single EQS for bots, instead of branching and following different targets.

So to follow VR camera I made BP_marker that reads VR camera location and snaps to it:

  • make BP_Marker, that is just empty blueprint
  • in it on event tick find player pawn, cast to your player pawn class
  • get camera reference, get its world transform
  • save that in variable inside BP_Marker
  • set transform for SELF to stored value (inside BP_Marker)

Make bots follow BP_Marker

never mind I got it, here’s how I did it. Let me know if I could do this better.

Thank you for this info, I have been busting my head for a while before stumbling on this thread. Can you please share your method if it differs from the others? Thank you!

what do you mean - set transform for SELF to stored value (inside BP_Marker)? I am making a VR game and needed to have the AI shoot at me right now the AI shoots off to the left of my VR pawn,

So far this is what I have

Im stuck at the next step I dont know what set transform for SELF to stored value (inside BP_Marker) means