diff --git a/Assets/Virtual Agents Framework/Runtime/Animations/AgentStandardController.controller b/Assets/Virtual Agents Framework/Runtime/Animations/AgentStandardController.controller
index d2a555bf..2a99964d 100644
--- a/Assets/Virtual Agents Framework/Runtime/Animations/AgentStandardController.controller
+++ b/Assets/Virtual Agents Framework/Runtime/Animations/AgentStandardController.controller
@@ -116,8 +116,7 @@ AnimatorState:
m_Name: Idle | Walk
m_Speed: 1
m_CycleOffset: 0
- m_Transitions:
- - {fileID: 2573289453217930312}
+ m_Transitions: [{fileID: 2573289453217930312}]
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
@@ -371,7 +370,8 @@ BlendTree:
m_Name: Blend Tree
m_Childs:
- serializedVersion: 2
- m_Motion: {fileID: -3772180338694805941, guid: c3b74a83e3d65e54f8af4de2bf2a139c, type: 3}
+ m_Motion: {fileID: -3772180338694805941, guid: c3b74a83e3d65e54f8af4de2bf2a139c,
+ type: 3}
m_Threshold: 0
m_Position: {x: 0, y: 0}
m_TimeScale: 1
@@ -379,7 +379,8 @@ BlendTree:
m_DirectBlendParameter: speed
m_Mirror: 0
- serializedVersion: 2
- m_Motion: {fileID: -3351673834204083825, guid: fe48fe4cd231c0c488b9c6b1c5f7e250, type: 3}
+ m_Motion: {fileID: -3351673834204083825, guid: fe48fe4cd231c0c488b9c6b1c5f7e250,
+ type: 3}
m_Threshold: 1.3988087
m_Position: {x: 0, y: 0}
m_TimeScale: 1
@@ -619,7 +620,8 @@ BlendTree:
m_DirectBlendParameter: Speed
m_Mirror: 0
- serializedVersion: 2
- m_Motion: {fileID: -3772180338694805941, guid: c3b74a83e3d65e54f8af4de2bf2a139c, type: 3}
+ m_Motion: {fileID: -3772180338694805941, guid: c3b74a83e3d65e54f8af4de2bf2a139c,
+ type: 3}
m_Threshold: 0
m_Position: {x: 0, y: 0}
m_TimeScale: 1
@@ -704,6 +706,60 @@ AnimatorController:
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
+ - m_Name: Speed
+ m_Type: 1
+ m_DefaultFloat: 0
+ m_DefaultInt: 0
+ m_DefaultBool: 0
+ m_Controller: {fileID: 9100000}
+ - m_Name: RotationDirection
+ m_Type: 1
+ m_DefaultFloat: 0
+ m_DefaultInt: 0
+ m_DefaultBool: 0
+ m_Controller: {fileID: 9100000}
+ - m_Name: ShakeHead
+ m_Type: 9
+ m_DefaultFloat: 0
+ m_DefaultInt: 0
+ m_DefaultBool: 0
+ m_Controller: {fileID: 9100000}
+ - m_Name: WaveLeft
+ m_Type: 9
+ m_DefaultFloat: 0
+ m_DefaultInt: 0
+ m_DefaultBool: 0
+ m_Controller: {fileID: 9100000}
+ - m_Name: WaveRight
+ m_Type: 9
+ m_DefaultFloat: 0
+ m_DefaultInt: 0
+ m_DefaultBool: 0
+ m_Controller: {fileID: 9100000}
+ - m_Name: NoAnimation
+ m_Type: 9
+ m_DefaultFloat: 0
+ m_DefaultInt: 0
+ m_DefaultBool: 0
+ m_Controller: {fileID: 9100000}
+ - m_Name: PointingLeft
+ m_Type: 9
+ m_DefaultFloat: 0
+ m_DefaultInt: 0
+ m_DefaultBool: 0
+ m_Controller: {fileID: 9100000}
+ - m_Name: PointingRight
+ m_Type: 9
+ m_DefaultFloat: 0
+ m_DefaultInt: 0
+ m_DefaultBool: 0
+ m_Controller: {fileID: 9100000}
+ - m_Name: IsRotating
+ m_Type: 4
+ m_DefaultFloat: 0
+ m_DefaultInt: 0
+ m_DefaultBool: 0
+ m_Controller: {fileID: 9100000}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
@@ -820,7 +876,8 @@ AnimatorState:
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
- m_Motion: {fileID: -4646348500681454183, guid: 7068b1601249e6046b5d8a08e0044cc0, type: 3}
+ m_Motion: {fileID: -4646348500681454183, guid: 7068b1601249e6046b5d8a08e0044cc0,
+ type: 3}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
@@ -872,7 +929,8 @@ AnimatorState:
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
- m_Motion: {fileID: -4646348500681454183, guid: 7068b1601249e6046b5d8a08e0044cc0, type: 3}
+ m_Motion: {fileID: -4646348500681454183, guid: 7068b1601249e6046b5d8a08e0044cc0,
+ type: 3}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
diff --git a/Assets/Virtual Agents Framework/Runtime/Scripts/ScheduleBasedExecution/ScheduleBasedTaskSystem.cs b/Assets/Virtual Agents Framework/Runtime/Scripts/ScheduleBasedExecution/ScheduleBasedTaskSystem.cs
index bb6d0712..966ccff9 100644
--- a/Assets/Virtual Agents Framework/Runtime/Scripts/ScheduleBasedExecution/ScheduleBasedTaskSystem.cs
+++ b/Assets/Virtual Agents Framework/Runtime/Scripts/ScheduleBasedExecution/ScheduleBasedTaskSystem.cs
@@ -33,6 +33,15 @@ private void Awake()
}
}
+ ///
+ /// Get the agent component of the game object
+ ///
+ /// The agent component
+ public Agent GetAgent()
+ {
+ return GetComponent();
+ }
+
public override void UpdateTaskSystem()
{
foreach (var taskManager in taskManagers.Values)
diff --git a/Assets/Virtual Agents Framework/Runtime/Scripts/ScheduleBasedExecution/TaskActions.cs b/Assets/Virtual Agents Framework/Runtime/Scripts/ScheduleBasedExecution/TaskActions.cs
index de5ff6f0..b6ecf385 100644
--- a/Assets/Virtual Agents Framework/Runtime/Scripts/ScheduleBasedExecution/TaskActions.cs
+++ b/Assets/Virtual Agents Framework/Runtime/Scripts/ScheduleBasedExecution/TaskActions.cs
@@ -227,5 +227,44 @@ public void ActivateOrDeactivateAdaptiveGaze(bool shouldStartOrStop, int priorit
AgentBaseTask adaptiveGazeTask = new AgentAdaptiveGazeTask(shouldStartOrStop);
scheduleTaskSystem.ScheduleTask(adaptiveGazeTask, priority, "Head");
}
+
+ ///
+ /// Use this function to make the agent point at a target object with one arm
+ /// If the target is behind the agent, the agent will first rotate towards the target
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public AgentBaseTask PointAt(GameObject target, bool aimLeftArm = false, bool aimRightArm = false, int aimAtTime = 5, int priority = 0)
+ {
+ AgentAnimationTask pointing = null;
+ Agent agent = scheduleTaskSystem.GetAgent();
+ // Add rotation before pointing if target is behind agent
+ Vector3 directionToTarget = target.transform.position - agent.transform.position;
+ float angleToTarget = Vector3.Angle(agent.transform.forward, directionToTarget);
+
+ // If the target is behind the agent (angle greater than 90 degrees)
+ if (angleToTarget > 90 && angleToTarget < 270)
+ {
+ // Schedule a rotation task towards the target
+ AgentRotationTask rotationTask = new AgentRotationTask(target);
+ scheduleTaskSystem.ScheduleTask(rotationTask, priority, "Left Arm");
+ }
+ if (aimLeftArm)
+ {
+ pointing = new AgentAnimationTask("PointingLeft", aimAtTime, "", "Left Arm", target);
+ scheduleTaskSystem.ScheduleTask(pointing, priority, "Left Arm");
+ }
+ else if (aimRightArm)
+ {
+ pointing = new AgentAnimationTask("PointingRight", aimAtTime, "", "Right Arm", target);
+ scheduleTaskSystem.ScheduleTask(pointing, priority, "Right Arm");
+ }
+ return pointing;
+ }
}
}
diff --git a/Assets/Virtual Agents Framework/Samples/Aiming Sample/Aiming Sample.unity b/Assets/Virtual Agents Framework/Samples/Aiming Sample/Aiming Sample.unity
index e3614a4f..dfae122d 100644
--- a/Assets/Virtual Agents Framework/Samples/Aiming Sample/Aiming Sample.unity
+++ b/Assets/Virtual Agents Framework/Samples/Aiming Sample/Aiming Sample.unity
@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
- m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
+ m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641258, b: 0.5748172, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@@ -769,13 +769,13 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1749989800}
serializedVersion: 2
- m_LocalRotation: {x: -0, y: -0.31255558, z: -0, w: 0.9498995}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.05, y: 1.5933, z: 3.7}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
- m_LocalEulerAnglesHint: {x: 0, y: -36.427, z: 0}
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1749989803
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -1135,11 +1135,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 700674713753034054, guid: 2962848ab48f0e4459691ff3d6d1eed0, type: 3}
propertyPath: m_LocalRotation.y
- value: -0
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 700674713753034054, guid: 2962848ab48f0e4459691ff3d6d1eed0, type: 3}
propertyPath: m_LocalRotation.z
- value: -0
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 700674713753034054, guid: 2962848ab48f0e4459691ff3d6d1eed0, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
diff --git a/Assets/Virtual Agents Framework/Samples/Aiming Sample/AimingSampleController.cs b/Assets/Virtual Agents Framework/Samples/Aiming Sample/AimingSampleController.cs
index 0022f2cf..b9880617 100644
--- a/Assets/Virtual Agents Framework/Samples/Aiming Sample/AimingSampleController.cs
+++ b/Assets/Virtual Agents Framework/Samples/Aiming Sample/AimingSampleController.cs
@@ -80,6 +80,10 @@ protected override void Start()
taskSystem.ScheduleTask(pointingRight, 0, "Right Arm");
}
}
+ // If you want the agent to rotate towards a target before pointing, you can use the PointAt TaskAction
+ AgentBaseTask pointAt = taskSystem.Tasks.PointAt(target, true, false, aimAtTime);
+
+ // or to rotate without using TaskActions you can use the AgentRotationTask
}
}
}
\ No newline at end of file
diff --git a/Assets/Virtual Agents Framework/Samples/Rotation Sample/Rotation Sample.unity b/Assets/Virtual Agents Framework/Samples/Rotation Sample/Rotation Sample.unity
index 9db43d7e..0d57a92f 100644
--- a/Assets/Virtual Agents Framework/Samples/Rotation Sample/Rotation Sample.unity
+++ b/Assets/Virtual Agents Framework/Samples/Rotation Sample/Rotation Sample.unity
@@ -1273,20 +1273,10 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
title:
- description: 'This scene demonstrates how to schedule walking tasks so that the
- agent navigates a series of waypoints.
-
- The script on the Controller object
- issues walking tasks to the agent on startup.
-
-
- Use the scene view during
- play mode to inspect the scene freely while the agent is walking around.
-
-
- If
- Objects are changed in the scene: Select the GameObject "NavMesh Surface" and
- bake the NavMesh again before running the scene.'
+ description: "This scene demonstrates the different types of rotation.\r\n\nThe
+ agent first rotates towards a target object (here the first waypoint), then towards
+ a coordinate (the coordinates of the second waypoint), \r\nand finally rotates
+ by 90\xB0 and then towards 90\xB0."
type: 0
url:
--- !u!4 &1264251852
diff --git a/Documentation/manual/task-system.md b/Documentation/manual/task-system.md
index e520b7a9..e013776a 100644
--- a/Documentation/manual/task-system.md
+++ b/Documentation/manual/task-system.md
@@ -19,6 +19,7 @@ Currently, the following tasks exist and can already be used:
- : Play animations on the agent
- : Let the agent walk to a given location or follow an object dynamically
- : Let the agent wait for a specific amount of time
+- : Let the agent rotate to a specific angle, towards a specific object or towards coordinates
- : Let the agent pickup an object next to them
- : Let the agent drop an object or all objects that the agent is holding
- : Starts or stops the [adaptive gaze](adaptive-gaze.md) feature.
@@ -59,10 +60,10 @@ In order to keep the code brief and understandable, it is not always necessary t
For common actions, it is also possible to call one of the shortcut functions on the agent.
Currently, the following shortcut functions exist:
-
- - : Let the agent walk to the specified coordinates.
- - : Let the agent walk to the specified transform of an object in the scene.
+ - : Let the agent walk and turn to the specified coordinates.
+ - : Let the agent walk and turn to the specified transform of an object in the scene.
You can add an optional offset so that the agent does not run into the object but stops next to it.
- - : Let the agent walk to the specified object in the scene.
+ - : Let the agent walk and turn to the specified object in the scene.
You can add an optional offset so that the agent does not run into the object but stops next to it.
The agent can also follow an object dynamically, so that the agent will follow the object until it is reached. Partial incomplete paths will be allowed, when that option is enabled.
@@ -76,4 +77,5 @@ Specifying a GameObject as an `aimTarget` for the animation, will start inverse
- : Drop the specified item if it is currently hold be the agent, if no item is specified, all items are dropped.
- : Schedules an GoTo Task that makes the agent walk to the specified coordinates or transform before dropping the specified item or all items, if no item is specified.
- : Start or stops adaptive gazing until it is stopped or started again. This is realized with a task that only runs once. This also automatically adds a component if the agent doesn't have one.
-- : Schedule a task that starts adaptive gazing for the specified time and then deactivates it by scheduling a wait task between a start and stop task.
\ No newline at end of file
+- : Schedule a task that starts adaptive gazing for the specified time and then deactivates it by scheduling a wait task between a start and stop task.
+- : Point at the specified object with the left or right arm. If the object is behind the agent, the agent will turn around to point at it.
\ No newline at end of file