May 22, 2012, 04:56:16 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Please report any bugs or issues that you might be encountering with the Beta in the Support System so that we can better keep track of any oustanding issues that may come up.

GameCore Support System
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Animation  (Read 430 times)
Squat
Hero Member
*****
Posts: 592


View Profile
« on: August 31, 2008, 04:32:29 AM »

I'd like to add some random idle animations to my character of any length.

I found this in the docs:
Quote
MotionTimeVar [name]
Specifies a motion variable to use for setting the time in this animation. This variable does not need to be previously declared, and can be modified in the game scripts. When the variable is set to zero then the animation is set to the beginning, when the variable is 1.0 then the animation is set to the end. For example, if a character had a simple animation of their head turning from left to right, then the variable can be set appropriately to get the character to look towards a specific angle.

Can this be both read and written? Can I get a usage example please? Just the line is fine, I'm after the syntax and don't want to start opening a bunch of scripts to find something at this late hour.
Logged
gekido
Guest
« Reply #1 on: September 08, 2008, 12:14:37 AM »

http://www2.gamecore.ca/docs/scripting-reference/classes/Object/SetMotionVariableFloat

This is the kind of thing that you would likely want to be updating on a regular basis, in your object's DynamicsAdvance or AnimAdvance functions.  You can see an example with setting the animation speed in the player script:

Code:
Vector linearVelocity = base.GetLinearVelocity();
Vector groundVelocity = linearVelocity;
groundVelocity.y = 0;
if (!dead)
{
object.SetMotionVariableFloat( "Velocity", groundVelocity.GetLength());
object.PlayAnim( "Move");
}

In this case we are setting two different types of motion variables, the MotionScalarVar and the MotionSelectVar.

From the soldier.opr in the FPS Multiplayer:
Code:

AddMotion IdleMotion
MotionAnim Idle
MotionSelectVar Velocity
MotionSelectMax 0.0
MotionFadeInTime 0.2

AddMotion WalkMotion
MotionAnim Walk
MotionScalarVar Velocity
MotionScalarRef 1.3
MotionSelectVar Velocity
MotionSelectMin 0.0
MotionSelectMax 3.0
MotionFadeInTime 0.2

AddMotion RunMotion
MotionAnim Run
MotionScalarVar Velocity
MotionScalarRef 3.0
MotionSelectVar Velocity
MotionSelectMin 3.0
MotionFadeInTime 0.2

AddMotion Move
MotionChild IdleMotion
MotionChild WalkMotion
MotionChild RunMotion

What this does is setup the various animations used by the 'move' motion and then defines a variable called 'Velocity' which we then use from script to control both the speed of the animations' being played (via the ScalarVar) and also which animation is being played (via the SelectVar).

By simply calling 'object.PlayAnim("Move");' and setting this Velocity variable, the engine will automatically switch between the idle, walk and run animations for the soldier and also control the speed of the animation accordingly so that the motions blend better.
Logged
Pages: [1]
  Print  
 
Jump to:  

 
Powered by MySQL Powered by PHP bluBlur Skin © 2006, hbSkins
Powered by SMF 1.1.14 | SMF © 2006-2011, Simple Machines LLC
Valid XHTML 1.0! Valid CSS!