How To Load Animations On A Npc Locally
Getting Started
The employ of scripted_sequences in maps is i of the things that make single player mapping that much more than versatile. Scripted_sequences are used to control npc characters and give them animations; it tin used to exhale life into an otherwise still scene.
For this example, we'll be making 2 npc_citizens carry out their everyday existence. The outset 1 volition walk to the couch and sit down on information technology while the other one will effort to get a TV working.
Firstly, create a room. Make information technology a reasonable size; mine was 256x448 (on acme view).
Place an info_player_start and a few lite entities in the room. Now (for the benefit of my case), place a couch in the room, and a Television on a table opposite it.
Choosing the Animations
Now we're going to set upwards our scripted sequences. Firstly, allow's see what animations we want the NPC'southward to have. Place an npc_citizen somewhere in the room, where is non important at the moment. Get into the properties and click the Model tab. Now get through the sequences, click a few to run across what they look like. This is the animations library, nosotros need the names of the animations we like to put in the scripted_sequence.
Okay, then for this instance I want to use the Idle_to_Sit_Chair, you can go and discover this to come across a demonstration.
Now name the npc. For my example ready the proper noun to npc_bob, and cut and paste him into a corner (moving them normally after setting upward an animation in the model tab can crash hammer, setting it back to Sequence: ragdoll can prevent this).
Now we want to place the scripted_sequence entity. Select information technology from the entity list and identify it on the flooring right in front end of the burrow (information technology's important not to place it in the couch. Scripts don't piece of work inside props or other entities). The small yellowish line in the pinnacle view shows which way the scripted_sequence is facing: you want information technology facing toward the TV. To modify this line, get to the scripted_sequence properties and change the angle.
Setting up the scripted_sequence
The fun function: go to the scripted_sequence properties and brand the Target Npc npc_bob. Nosotros'll fix the entry animation to Idle_to_Sit_Chair. Set the action animation to Sit_Chair and set the post action animation to Sit_Chair. Move to Position should exist set to Walk. You can also make him run or become to the sequence instantly. Go to the flags tab and tick Override AI, Loop in Post idle and Priority Script. This basically means the NPC will practice this despite distractions and will proceed sitting, even after the script is finished.
Testing the sequence
Name the scripted_sequence script_bobsit. At present, create a func_button on the wall somewhere and prepare the Output to: Onpressed, Target entity: script_bobsit, Via this output: Begin Sequence. At present would be a good time to examination, so compile and load it up. Press the button and see if the npc does the sequence.
Role 2: Fixing the Television set
Now we're going to set the other npc, the ane that'll try to get the Tv set working.
Identify another npc_citizen in another corner of the room. Name this one npc_paul. Now place a scripted_sequence in front of the TV you placed earlier, and set the bending to face the TV. Set the Target NPC to npc_paul. Fix the Entry Blitheness to standtocrouchhide, fix the action blitheness to crouchidlehide and the Postal service activeness idle Animation to crouchhidetostand. This time withal, the npc will not be looping the animation, in which case the only flags you lot need to tick are override AI and Priority Script. Tick the Repeatable flag every bit well.
Name the scripted_sequence script_paulfix and place another button. This button will be: OnPressed, Target Entity: script_paulfix, Via input: BeginSequence.
Conclusion
If you lot've followed this correctly, y'all should be able to get both npc'southward going by pressing their private buttons. If you ticked the Repeatable flag, you lot can press the TV guy's button more than once. Compile and exam.
Of course, this is just a starting indicate for what you tin can do with scripted_sequences. I hope this gives y'all many ideas and has taught you how to use them effectively.
Source: https://twhl.info/wiki/page/Tutorial:_NPC_Scripting_Basics
Posted by: henselpaing1953.blogspot.com
0 Response to "How To Load Animations On A Npc Locally"
Post a Comment