Sign in to follow this  

Sync animation with effects?

This topic is 3939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a question on how to sycn amimation with the related effect. An example: if a character shoots an arrow at another character and kills him, the character should not fall down until after the arrow has impacted. In a turn-based combat situation you can calculate immediately what the result of an action will be (a kill result from the arrow attack), but must wait to apply the effect until after the animaton plays. What's the best way to handle this situation? Currently, I've been cloning the target character, applying the effect to the clone, then replacing the target character with his clone after the animation plays. It works, but seems excessive. Most of the examples I've found use collision detection which is more that I really need. Any help is appreciated. Regards

Share this post


Link to post
Share on other sites
Your arrow animation is probably a function by itself. Why not just encapsulate that function inside a larger wrapper that calls the animation function, calculates the result, and plays the proper response animation? You can set your arrow animation to play until it reaches your destination tile so no reactions will be made until it's finished.


void animate_attack(Actor *attacker,Actor *target) {
attacker->attack_animation(attacker->loc,target->loc);
calculate_damage(attacker->damage,target->defense);
if target->hp <= 0 {
target->death_animation();
} else target->hit_animation();
}



...in pseudo code.

Share this post


Link to post
Share on other sites
Thanks for the feedback. Unless I'm reading it incorrectly your example works if you are not running a "game loop". I can't draw the arrow moving from the start location to end location on its own since other things might be animated at the same time (torches, water, etc...) during each frame.

As an fyi, I'm using the XNA framework.

Regards

Share this post


Link to post
Share on other sites
You're absolutely right, and from how I read your example, it sounded like no parallel animations would be used (sorta like Civilization without the environment animations). I'm on my way to work, but I'll think on this a bit more. Cheers.

Share this post


Link to post
Share on other sites
Do you have this all encapsulated in an arrow class?

If so then set the target pointer when you fire the arrow
Have a function called in the arrow when the animation finishes
In this function have the:



{
calculate_damage(attacker->damage, target->defense);
if target->hp <= 0 {
target->death_animation();
} else target->hit_animation();
}




It should work if you have all this wrapped in a class.

Share this post


Link to post
Share on other sites

This topic is 3939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this