Npc dog/Playing fetch with Dog: Difference between revisions
No edit summary |
mNo edit summary |
||
Line 27: | Line 27: | ||
==Known issues== | ==Known issues== | ||
{{bug|There appears to be a bug where D0G won't start playing | {{bug|There appears to be a bug where D0G won't start playing catch-and-throw even when everything is in place (all the inputs have been fired, there's valid [[nodegraph]], etc.), ''until he makes a step''.}} | ||
It may have gone unnoticed in '''Half-Life 2''', because he always runs toward his dumpster, and therefore 'wakes up'. To fix it, you can either stage it like '''HL2''' - have him run toward a target to start playing - or place a [[aiscripted_schedule]] entity near him to make him walk toward it; just a short distance should be sufficient. | It may have gone unnoticed in '''Half-Life 2''', because he always runs toward his dumpster, and therefore 'wakes up'. To fix it, you can either stage it like '''HL2''' - have him run toward a target to start playing - or place a [[aiscripted_schedule]] entity near him to make him walk toward it; just a short distance should be sufficient. | ||
Line 40: | Line 40: | ||
* Are placed above his [[$eyeposition|eye position]]. | * Are placed above his [[$eyeposition|eye position]]. | ||
{{bug|While D0G is capable of playing | {{bug|While D0G is capable of playing catch-and-throw with a target other than the player (even another D0G),{{ref|1}} he'll always turn face the player before throwing.}} | ||
==References== | ==References== | ||
# {{youtube|pyvAJlF8Jfg|page=watch| Two npc_dogs playing fetch with each other}} on '''YouTube''' | # {{youtube|pyvAJlF8Jfg|page=watch| Two npc_dogs playing fetch with each other}} on '''YouTube''' |
Revision as of 15:08, 11 July 2024
D0G's AI is largely dedicated to picking up physics objects and playing fetch with a target (usually, the player).
As shown in Half-Life 2, D0G can grab objects with his built-in Gravity Gun, toss them over an arcing trajectory, wait for it to be thrown back at him, and either repeat that cycle, or search a new object dynamically.
While the logics setup used in Eli's junkyard (d1_eli_02) might seem frighteningly complex, a large portion of it has to do with spawning new crates dynamically, and tracking their fate (enabling D0G to act disappointed or excited), and then switching to play with his deactivated Rollermine. As well as a handful of scripts related to Alyx.
The actual setup to play fetch with D0G is not that complicated:
- Use npc_dog in his most basic 'configuration', that is - not distracted by combat, scripted sequences, or follow behavior; all of them usually make his AI switch away from the fetch game.
- Have prop physics available to him.
- Now use the following Inputs to make him play fetch:
SetThrowTarget
<name of the target> (leave blank to use the player);StartCatchThrowBehavior
<name of the prop> to switch to his play AI (leave blank to search for an object dynamically);- Make D0G walk or run to where you want him to be, by using aiscripted_schedule, scripted_sequence or a choreo scene (see Known Issues for explanation).
That should be enough for the basic routine. Other inputs can modify or stop it:
SetPickupTarget
<name of the prop> overrides his preferred prop;StopCatchThrowBehavior
for him to stop altogether;SetThrowArcModifier
<float> to alter the trajectory;StartWaitAndCatch
Todo: ExplainStopWaitAndCatch
Todo: Explain

StartCatchThrowBehavior
(blank) and make him move. That can be enough.Known issues
It may have gone unnoticed in Half-Life 2, because he always runs toward his dumpster, and therefore 'wakes up'. To fix it, you can either stage it like HL2 - have him run toward a target to start playing - or place a aiscripted_schedule entity near him to make him walk toward it; just a short distance should be sufficient.
If D0G waits too long, he'll give up and search for another prop. His heuristics isn't perfect, and it may lead to unindended consequences and even get him stuck, if he tries to grab a prop that's lodged in scenery, tied to constraints and otherwise not meant for him. There doesn't seem to be a way to filter out what prop he can grab without additional programming, so you'd have to plan for it by not having any unintended physics lying around, or disabling their motion.
D0G won't attempt to grab objects that are:
- Flagged as debris or interactive debris;
- Held by the player;
- Have their motion disabled;
- Are heavier than 250kg (this figure is hardcoded);
- Aren't visible to him;
- Are placed above his eye position.
References
Two npc_dogs playing fetch with each other on YouTube