Copyentity maintain animations??
Blitz3D Forums/Blitz3D Programming/Copyentity maintain animations??
| ||
Hi all, I've been making some trials instancing actors with animation. In order to save load time, I used copyentity to make different copies of these models, but when I played their animations, it seems that the animate function ignore them!. When I load the model I extract all its animations with extractanimseq, no problem, each animation is played along the different behaviour states of the actor if it is not a instanced entity, but at the moment I use copyentity to copy the main loaded entity and try to run again, the actor uses strange animations, ignoring the extracted ones. Make sense??? Someone knows something about animations and copyentity? thanks in advance! |
| ||
just off the top of my head, and without researching the problem at all, have you tried CopyMesh instead? |
| ||
Try copyEntity and extract the animations again? |
| ||
Using copyentity should allow you to use the animations of the entity you copy, it's how i have done it with no issues. eg baseentity = loadanimmesh("actor.b3d") walk = loadanimseq(baseentity) actor1 = copyentity(baseentity) animate actor1,1,1,walk EDIT: Sorry i don't use extract so that might be the problem? |
| ||
I've never had a problem with animations not working with models returned from CopyEntity :-/ Not sure why you're having a problem, should work exactly the same... |
| ||
You need to use ExtractAnimSeq before copying the entity, otherwise the anim sequences won't be copied with the entity and you will need to use ExtractAnimSeq again after copying. |
| ||
Thanks a lot! More or less I start to have a little idea, but still having some doubts.. This is what I'm doing now dim instances(64) .... .... ;-------------------- ; Load base entities ;-------------------- instance(1) = loadanimmesh("actor1.b3d") instance(2) = loadanimmesh("actor2.b3d") .... .... type actortype field x,y,z field ent field root field anm[64] endtype .... .... function create_actor() actor.typeactor = new typeactor actor\ent = copyentity(instance(1)) actor\root = findchild(actor\ent,"root") actor\anm[1] = ExtractAnimSeq (actor\root,0,120) actor\anm[2] = ExtractAnimSeq (actor\root,121,154) actor\anm[3] = ExtractAnimSeq (actor\root,154,190) ..... ..... end function .... .... This is the way in which my animations fails, as I've commented before. If I change the 'copyentity' command by 'loadnimmesh', it works. In which way I should change the order?? Extracting the animations from the base entity?? Please, could you clarify this? Thanks in advance! |
| ||
Try extracting from the base entity first - you then dont need to extract the sequences for each copied instance. Also you dont need to store the values of the extracted sequences unless you use descriptive variable names like "walk", "run" etc. In the following code : actor\anm[1] = ExtractAnimSeq (actor\root,0,120) actor\anm[2] = ExtractAnimSeq (actor\root,121,154) actor\anm[3] = ExtractAnimSeq (actor\root,154,190) ...the value "actor\anm[1]" will always be 1 , "actor\anm[2]" will always be 2 and "actor\anm[3]" will always be 3 etc. dim instances(64) global idle,walk,run ;examples of variables to store sequence identifiers .... .... ;-------------------- ; Load base entities ;-------------------- instance(1) = create_base_actor1() instance(2) = create_base_actor2() .... .... type actortype field x,y,z field ent field root field anm[64] endtype .... .... function create_base_actor1() mesh=loadanimmesh("actor1.b3d") root = findchild(mesh,"root") idle=ExtractAnimSeq (root,0,120) walk=ExtractAnimSeq (root,121,154) run=ExtractAnimSeq (root,154,190) return mesh ..... ..... end function .... function create_base_actor2() mesh = loadanimmesh("actor2.b3d") root = findchild(mesh,"root") ExtractAnimSeq (root,0,120) ExtractAnimSeq (root,121,154) ExtractAnimSeq (root,154,190) return mesh ..... ..... end function function create_instance_actor1() actor.typeactor = new typeactor actor\ent = copyentity(instance(1)) ..... ..... end function function create_instance_actor2() actor.typeactor = new typeactor actor\ent = copyentity(instance(2)) ..... ..... end function |
| ||
thanks a lot smiff!! I will try it inmediately! thanks!!!!!!! regards! |