Assuming you design your own characters and then the animations.
Step 1
Create the character
Step 2
Create the animations. (walk, run, jump, crouch, shoot, attack, die, etc.
Step 3
Create a script that runs the character's animations.
Since the animation is divided into frames, the script must execute these frames according to the situation, for example if the character is in danger he has to run, if he sees an enemy he will have to shoot, etc.
The animations should be declared in the fpe file, example:
;anim
animmax = 5
anim0 = 100,205 ;idle
anim1 = 685,707 ;move
anim2 = 5511,5553 ;kick
anim3 = 4812,4850 ;hurt
anim4 = 515,605 ;reload
playanimineditor = 1
ignorecsirefs = 1
As you can see above, move animation goes from frame 685 thru frame 707 and it is the anim1, so if you want to call it in order to get the char moving then you will has to call animation 1 in the script, via LUA command such as:
SetAnimation(1) -- state animation 1
PlayAnimation(e) -- play the animation 1
If in any moment you want to stop it, so you'll use: StopAnimation(e,1) -- "e" is the entity id, and 1 referring to animation #1
If you want the animation looping then you'll use: LoopAnimation(e) LUA command.
SetAnimation(2) -- state animation 2
LoopAnimation(e) -- loop the animation 2
Or you can directly call anims via :
PlayAnimation(e,1) -- run animation #1
LoopAnimation(e,2) -- Loop animation #2
Or you can call animations by frames, such as:
SetAnimation(1)
SetAnimationFrames(685,707)
PlayAnimation(e)
IMPORTANT
In order to run any script the entity should be Dynamic, Static entity does nothing besides to be part of the environment.
However, you can access the id of a static entity, provided you do not discriminate it in the script, for example:
To access / interact only with dynamic entities:
for n = 1,g_EntityElementMax,1 do -- loop thru all the entities
if g_Entity[n] ~= nil then -- looking just for dynamic ones.
--your code here
end
end
To access / interact with all entities:
for n = 1,g_EntityElementMax,1 do -- loop thru all the entities
--your code here
end
If you want your script being player distance based, so:
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 180 then
-- your code here
end
so, all together:
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 180 then
SetAnimation(1) -- state animation 1
PlayAnimation(e) -- play the animation 1
end
Note1: If you want run your anim without script you'll have to state it in the pfe file, such as:
playanimineditor = 1
Obviously this is a very summarized definition, but it is a good starting point.
hth
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz
OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4