Pawn looking at

I have been experimenting with several techniques and the following one might work for you.

What you need.

  1. A blueprint BP_WayPoint extended from Actor with the following setup.

Event attached to ‘Begin Overlap’
3ef0a4422ad4adacbbf87db4c8e0ef3a6047ab95.jpeg

  1. A blueprint extended from Pawn/Character with the following setup.
  1. A blueprint extended from HUD with following event graph to display Wrong Way text.

How does it work:

The BP_Waypoint blueprint must be placed along the track to indicate waypoints. The rotation of this Actor indicates the desired rotation of the car at that point (the arrow component will help with this). You dont have to be very precise. You need to place these actors wherever there is change in direction in the track. You can place them in branches as well. Edit the property of ‘Radius’ to set the correct radius for the collision sphere.

The Pawn has a reference to one instance of BP_Waypoint actor. This is set when Pawn overlaps with a Waypoint. We use the function SetActiveWaypoint function to do this.

At each tick, we find the difference between the rotation of the pawn and rotation of ActiveWaypoint. If the difference of Yaw is above a threshold (160 degrees in this example), we set bWrongWay to TRUE, otherwise FALSE.

In the HUD, we simply check the value of bWrongWay and display the warning.

This is a very basic setup. You must take velocity, reversing etc into consideration. This implementation only looks for the rotation of the Pawn. You can for instance set WrongWay only after Pawn has moved in the wrong direction for a minimum of X distance or Y seconds… Do this in tick and set bWrongWay accordingly. You can add additional code inside SetActiveWaypoint to optimize things and also to make more complex stuff.

This method works with branches as well. However just try to avoid overlaping waypoints.