Search the Community
Showing results for tags 'setAnimation'.
-
Hi guys, I was looking into "character system" for how to load animations and play them. I came across some code which actually confused me. This is from actor.h from one of the samples : string animations[] = ( STATE_WALK_IDLE : "idle.sanim", STATE_WALK_JUMP : "jump.sanim", STATE_WALK_FORWARD : "walk_fwd.sanim", STATE_WALK_BACKWARD : "walk_bwd.sanim", STATE_WALK_MOVE_LEFT : "walk_lt.sanim", STATE_WALK_MOVE_RIGHT : "walk_rt.sanim", STATE_WALK_TURN_LEFT : "walk_lt.sanim", STATE_WALK_TURN_RIGHT : "walk_rt.sanim", STATE_RUN_FORWARD : "run_fwd.sanim", STATE_RUN_BACKWARD : "walk_bwd.sanim", STATE_RUN_MOVE_LEFT : "run_lt.sanim", STATE_RUN_MOVE_RIGHT : "run_rt.sanim", ); PlayerActorSkinned(PlayerActor a) { actor = a; mesh = add_editor(new ObjectMeshSkinned("samples/players/meshes/actor_00.smesh")); for(int i = 0; i < mesh.getNumSurfaces(); i++) { mesh.setMaterial(get_material(i),i); mesh.setProperty("surface_base","*"); mesh.setCollision(0,i); } mesh.setNumLayers(7); foreach(string animation; animations) { animation = "samples/players/meshes/actor_00/" + animation; mesh.setAnimation(animation); } } void set_layer(int layer,float weight) { mesh.setLayer(layer); mesh.setWeight(weight); } void set_frame(int state,float time) { if(mesh.getWeight() > EPSILON) { mesh.setAnimation(animations[state]); mesh.setFrame(time * fps[state]); } } My confusion : -Why setAnimation function take different arguments once with path and once without path. -Will it always load animation from external file, that's what description of the function says. Isn't it slow bcoz second setAnimation is being called from "::update" ? And one more thing can we TWO set animations in one LAYER so blend them or each animation must be in separate layer ? BTW, character system is really helpful. Thanks Thanks