If you truly are totally new to scripting in RF, I would recommend you to read the 'Introduction to Pawn Scripting' part in the e-book 'Making 3D Games with Reality Factory'. I would probably fail in explaining the basics and only confuse you. You can get the e-book for free
here.
I really suggest you to learn the basics of scripting because it's really hard to explain these things otherwise.
All the scripting commands are listed in the RF manual found in 'docs' folder under your RF folder. There's not just one way to animate an entity that works in every situation.
Scripting animations for the player (the main character) is a lot harder than doing that for NPC's. The 'player' itself doesn't run any script. It's hardcoded into the game engine so it's much harder to customize than the script-controlled 'pawns'. 'Pawns' are used as the NPCs of your game, but they can also be used as different kinds of gameplay controllers.
The easiest way of animating an entity is probably animating a NPC. You can do it simply by using scripting commands that make the pawn play an animation.
High level: Delay(), PlayAnimation(), BlendToAnimation(), LoopAnimation(), AnimationSpeed(), AnimateStop()
Low level: Animate(), AnimateHold(), AnimateBlend(), AnimationSpeed()
Check the manual for more info on what the different commands do.
Let's take an example:
Code: Select all
{
Spawn[ ()
{
PlayAnimation("idle",true,"idlesound");
RestartOrder();
}
}
That's a simple script with one 'order' called 'Spawn'. It only plays an animation called "idle" and when it finishes, it restarts the order and plays the animation over and over again.
It will take me hours to write this post if I go deeper into this, so I'll just say that by combining commands you can have very complex NPCs with a really interesting behaviour.
Scripting player animations is a bit more tricky. Playing the animation itself isn't too hard. There's a command called 'AnimateEntity()' which lets you animate any entity in the level (the Player, a certain Pawn, StaticEntityProxy or a StaticMesh). I have never used the command and I can't be sure of its functionality, but since it's officially included in RF, I believe it works.
The tricky part is checking which animation needs to be played.
For example, if you wanted to have a 'yawn' animation, you would first have to check how long the player has been standing still. Then you would compare the time to a time you have specified and possibly play the animation.
Or if you wanted a 'sit' animation, you would have to check if the player is in a correct place, say, near a chair. Then you would have to check if the player is 'told' to sit down, for example a certain button is pressed or a trigger is activated. After these checks the script would decide whether to play the sit animation or not.
The hard part is that all this checking stuff needs a lot of improvising! You may have to build very complex systems even for simple tasks like those I mentioned above. But after the checks are done, the animation is easy to play.
I hope I made sense, even a tiny bit. I have a tiny fever and the biggest headache of all times, so forgive me if I confused you.
![Smile :)](./images/smilies/icon_smile.gif)
Feel free to ask anything.
Pain is only psychological.