Page 1 of 1

Scripting for new animations, how?

Posted: Thu Feb 15, 2007 6:38 pm
by Phaegin
Please forgive me if this question has been answered already, as can be seen by the data to the left of this, I am new here, and while I have tried to be thorough in my searching of this forum (with many rewarding sights! Thank you to the helpful ones! :) ) I may well have missed the data I want most.

Keeping in mind, please, that I have spent the majority of my adulthood living in the right side of my brain (illustration and 3d modeling primarily), I have unfortunately allowed any technical potential to languish, so any help forthcoming would be appreciated most if the teacher would use small words, and type slowly :)

Is there available a step-by-step tutorial on scripting in animations not included in Reality Factory, such as eating and sitting down, just to name them as possibilities? If so, would someone be kind enough to tell one where?

Failing this, and I am sensible that it may be much to ask, would anyone with the knowledge be willing to post a reply, detailing as for one that knows no real programming, each step in scripting for a new animation, as though one were teaching a small child, for I fear that may be my status as a programmer :(

I thank you in advance for any help.

Posted: Thu Feb 15, 2007 7:34 pm
by Juutis
First of all, very welcome to the forums! :D

And secondly, do you mean scripting animations for the main character or NPC's?

Posted: Thu Feb 15, 2007 11:05 pm
by Phaegin
I thank you for your welcome :)

I would like to know how to do both, certainly, although my interest is in primarily the actions of a main character. I would most be interested in the knowledge of how to introduce an animation which takes place under a given circumstance, in the same manner that the walking animation occurs at any time the character is made to go forward without run, or the happening of the Die animation when health=0.

I search for greater potential to humanize, through actions such as sitting, sleeping, eating, or perhaps even yawning when Idle has been happening for a greater length of time.

I am sensible that my English is imperfect, I am attempting to improve, and I thank you for your patience.

Posted: Fri Feb 16, 2007 11:56 am
by Juutis
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. :)
Feel free to ask anything.

Posted: Sat Feb 17, 2007 12:20 am
by Phaegin
My sincere thanks!

I have learned from your post, and now I have at least a place to begin. Hopefully (?) I will be able to accomplish what I desire, but even if there is no success, much of the enjoyment is from new things :)

Please rest, so that you may feel better.