8 protected float m_fAsideMoveDistance;
10 protected static const string VEHICLE_PORT =
"Vehicle";
11 protected static const string POSITION_PORT =
"Position";
13 override bool VisibleInPalette() {
return true; }
15 override string GetOnHoverDescription()
17 return "Returns position for a character to avoid a vehicle.";
20 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
22 IEntity myEntity = owner.GetControlledEntity();
25 GetVariableIn(VEHICLE_PORT, vehicle);
26 if (!vehicle || !myEntity)
27 return ENodeResult.FAIL;
30 vector myPos = myEntity.GetOrigin();
31 vector myPosVehicleSpace = vehicle.CoordToLocal(myPos);
34 vector vehicleAside = vehicle.GetTransformAxis(0);
36 if (vehicleAside.LengthSq() < 0.01)
41 vector vectorAwayFromVehicle = vector.Direction(vehicle.GetOrigin(), myPos);
42 vectorAwayFromVehicle.Normalize();
44 vector posOut = myPos + m_fAsideMoveDistance * vectorAwayFromVehicle;
45 SetVariableOut(POSITION_PORT, posOut);
49 vehicleAside.Normalize();
51 vector myOffsetDirection = vehicleAside;
52 if (myPosVehicleSpace[0] < 0)
53 myOffsetDirection = -myOffsetDirection;
55 vector posOut = myPos + m_fAsideMoveDistance * myOffsetDirection;
57 SetVariableOut(POSITION_PORT, posOut);
60 return ENodeResult.SUCCESS;
63 protected static ref TStringArray s_aVarsIn = { VEHICLE_PORT };
64 override TStringArray GetVariablesIn() {
return s_aVarsIn; }
66 protected static ref TStringArray s_aVarsOut = { POSITION_PORT };
67 override TStringArray GetVariablesOut() {
return s_aVarsOut; }