Scripts / Control of Character Animations

Author
Message
Go Devils
11
Years of Service
User Offline
Joined: 13th Aug 2012
Location: Phoenix Arizona USA
Posted: 12th Jan 2015 06:14
I put together the following script in an attempt to create my own control over character animations. This script works a little, so that as I move the character with the MoveFoward(e,v) function the base animation (walking) makes it appear that the character is walking across the environment. However, I want to be able to stop the movement and switch the animation to the Neutral standing animation.



In the FPE, I set the following
;anim
animmax = 2
anim0 = 3870, 3900
anim1 = 3000, 3100

anim0 is the walking animation
anim1 is the neutral standing

As I said, the walking animation works, but I cannot figure out how to change to and from anim1 ??

Also, is there a limit to the number of animations that can be in operation at the same time?

Thanks and GO DUCKS!

There is no Spoon...
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 12th Jan 2015 19:44
use SetAnimation(#) & PlayAnimation(#)
and replace the # with the number given inside the fpe

i.e. to walk
SetAnimation(0)
PlayAnimation(0)
and to idle change the 0s to 1s.

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Go Devils
11
Years of Service
User Offline
Joined: 13th Aug 2012
Location: Phoenix Arizona USA
Posted: 13th Jan 2015 06:42 Edited at: 13th Jan 2015 06:44
Thanks smallg



I took your advise and got it to work partially. However, using the SetAnimation(#) instead of (e) does not work???



Here's the code







With this code, the combat soldier stands in idle mode for a count of 500 at which time the walking animation is activated and the character moves forward with the walking animation perfectly



At the count of 2500 the walking stops but the character will not display animation 2 (another idle standing animation).



At 3999 the walking mode continues and the walking animation works fine once again.



At the conclusion of the 2nd walk, the animation stops again, but the idle animation does not work.



Funny side note... if I insert CharacterContolUnarmed(e) at the conclusion of end of the 2nd walk, the character turns around and walks back to the starting point and then stops????



Very strange ...

There is no Spoon...
Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 13th Jan 2015 09:59 Edited at: 13th Jan 2015 14:41
I haven't played with characters and their animations yet, but just a quick tip: Never use counter for "timed" events, because counter can go slower or faster on different CPUs, or even on the same CPU depending how far you are from the object - use timer instead.

Go Devils
11
Years of Service
User Offline
Joined: 13th Aug 2012
Location: Phoenix Arizona USA
Posted: 13th Jan 2015 17:55
Hi Avram,

Thanks for the tip. I think I kinda understand.
In my code I created two timer variables and incremented them in the script, as opposed to using the FPSR timer.
I think that's what you are referring to, correct? These were used more as triggers than timers.

This said I took a look at your OOP LUA framework post, and while I don't fully understand it, I'd like to look deeper into it. How can I get a copy and/or documentation?

Also, I'm just about to integrate OmegaCORE into my system. Have you used these extensions?

Thanks Again
Go Devils

There is no Spoon...
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 13th Jan 2015 18:38
try removing the stopanimation calls and test again, i dont think you need those as only 1 animation should be played and looping alone should be enough to start the next animation
also it might just not be realising that your variable is hitting 2500 fast enough as it will change very fast on a high fps and by the time it checks it may already have passed it, same for the last part

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Go Devils
11
Years of Service
User Offline
Joined: 13th Aug 2012
Location: Phoenix Arizona USA
Posted: 13th Jan 2015 19:26
Hi Smallg
Thanks as usual

I have tried this without the StopAnimation, and just about every other combination I can think of.

Without StopAnimation the character stops moving (because the MoveForward command is not active), but the walking animation continues, even though I have Set and Looped the new animation. I'm beginning to wonder if this has something to do with the special status that characters have in relation to the FPSR engine. As you suggested, I tried using the SetAnimation(#) with the animation number, but this does not work unless the SetAnimation is set to (e)???

In the CombatSoldier.FPE, all of the different animations are listed as follows



What is the csi_name used for? Can this csi_ designation be used to define an animation in the LUA script?

Thanks again
Go Devils

There is no Spoon...
J_C
16
Years of Service
User Offline
Joined: 9th Nov 2007
Location:
Posted: 13th Jan 2015 20:57
PM
Avram
GameGuru TGC Backer
17
Years of Service
User Offline
Joined: 3rd Sep 2006
Location: Serbia
Posted: 13th Jan 2015 21:04 Edited at: 13th Jan 2015 21:05
Go Devils wrote: "In my code I created two timer variables and incremented them in the script, as opposed to using the FPSR timer.

I think that's what you are referring to, correct? These were used more as triggers than timers."




Those are not "timer variables", but counters, and for example on very fast machine it can loop 500 iterations in half a second, while on slow machines it can take whole second. Usually the times are slower than this but they are affected by the CPU speed, unlike timers which use system clock. Also note that in my OOP LUA framework timers count in seconds, while Reloaded timers count in milliseconds (my timers use LUA clock which is precise to one second and they were introduced before Reloaded timers were implemented). Also, distance from the entity also plays role in how fast your _main() function will be invoked, thus affecting your counters too. At least this was the case with FPSC Classic.



Go Devils wrote: "This said I took a look at your OOP LUA framework post, and while I don't fully understand it, I'd like to look deeper into it. How can I get a copy and/or documentation?"




You can download it and access documentation here: https://bitbucket.org/Avram/fpsc-r-toolkit

Feel free to send me a PM if you need further explanation as the thread about OOP LUA framework was automatically locked after 30 days of inactivity.

Go Devils
11
Years of Service
User Offline
Joined: 13th Aug 2012
Location: Phoenix Arizona USA
Posted: 14th Jan 2015 05:39
@Avram

Your right on with the timers, and correct that what I was using are counters.
I like using counters for some things, but I understand that some applications will require real time, not FPSR Engine time.

I'm very interested in your toolkit
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 14th Jan 2015 14:01
yep looks like setanimation has changed, maybe something to do with the new fpe setup, who knows
anyway it works using SetAnimationFrames(start#,end#)

so for example


etc - you would just need to determine what those conditions are
the only downside is you have to now script in each value of the animations yourself rather than just being able to set them in a specific order via the fpe if you wanted to use the same script for multiple entities with different animation frames

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Go Devils
11
Years of Service
User Offline
Joined: 13th Aug 2012
Location: Phoenix Arizona USA
Posted: 14th Jan 2015 18:31
Thanks smallg

Had not thought of that. I'll give it a try later on and let you know.

Go Devils

There is no Spoon...
GoDevils
9
Years of Service
User Offline
Joined: 24th Sep 2014
Location: Arizona USA
Posted: 20th Jan 2015 04:49
@smallg

Your where right on again. The use of the SetAnimationFrames(x,z) did the trick.

Now the masked soldier stands for a moment, then walks forward a little, then stops and changes to a relaxed standing animation, then he starts walking again, a
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 20th Jan 2015 19:11
glad you got it working, it works with any animations as long as you know the frame ranges... it is however easier to make the built-in characters do stuff like idle, walk and run etc as there are already commands for those without needing to worry about the frames
SetCharacterToWalk(e)
CharacterControlStand(e)
CharacterControlArmed(e)
etc

setting animations is more for custom characters

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11

Login to post a reply

Server time is: 2024-05-07 16:31:36
Your offset time is: 2024-05-07 16:31:36