Multipart Actor Problem (solved)

I followed the tutorial for multipart actors on this site and my models both share the same skeleton just different mesh objects but when I start my code I get this as the result.

s165.photobucket.com/albums/u60/ … shound.flv

class Player(Actor.Actor):
    def __init__(self):
        Actor.Actor.__init__(self)
        self.loadModel("plainshoundJaw.egg", partName = "Jaw")
        self.loadModel("plainshoundBody.egg", partName = "Body")
        self.loadModel("plainshoundtail.egg", partName = "Tail")
        self.attach("Body", "Tail", "Lower Back")
        self.attach("Body","Jaw","Jaw")
        self.loadAnims({"Open":"plainshoundJaw-Open.egg"}, partName = "Jaw")
        self.loadAnims({"Between":"plainshoundtail-Between.egg"}, partName = "Tail")
        self.loadAnims({"Wag":"plainshoundtail-Wag.egg"}, partName = "Tail")
        self.loadAnims({"Idle":"plainshoundBody-Idle.egg"}, partName = "Body")
        self.loadAnims({"WalktoRun":"plainshoundBody-WalktoRun.egg"}, partName = "Body")
        self.loadAnims({"Run":"plainshoundBody-Run.egg"},partName = "Body")
        self.reparentTo(render)
        self.loop("Wag","Tail")
        self.loop("Run","Body")
        self.loop("Open","Jaw")

Thats my code.

Does anyone have any ideas on why this is happening and how to fix it? Thanks in advance.

Try not making the attach() call. This call is only appropriate if you have designed each part so that its entire joint hierarchy can be assigned underneath the joint you name. That would mean that the subpart does not have the entire skeleton, but rather just the part of the skeleton below the named joint; and furthermore that there is no animation on its root joint.

Of course, if you avoid the attach() call, it means your parts will tend to fly apart if you put different animations on them. So you really want to use the attach() call, but this means you need to strip the animations off of the top joints.

You can use the tool egg-topstrip for this purpose. You can egg-topstrip on each of your subparts, to strip away the animation of the joint you are going to attach it to. That way, when you attach it to that joint, it will inherit its animation naturally.

On the other hand, if your only intention is to be able to play different animations on the different parts of your animal, you will probably find it much easier to use the newer “subpart” Actor feature. With this feature, you can define and load just one intact model, and after it is loaded you define certain groups of joints as “subparts”, which can be animated independently. See Actor.makeSubpart() in the API documentation.

David

I think i’m going to try using that subpart feature as it serves my purpose for multi parting my actor.

Would you able to help me with that? I’ve coded in what I think is right from readint the API documentation on it but when I play only the idle animation plays not the tail wagging.

class Player(Actor.Actor):
    def __init__(self):
        Actor.Actor.__init__(self)
        self.loadModel("plainshound.egg")
        self.loadAnims({"Idle":"plainshound-Idle.egg"})
        self.makeSubpart(
        partName = "Body",

        includeJoints=["Center"],
        excludeJoints=["Jaw","Tail 1"],
        parent="modelRoot")

        self.makeSubpart(
        partName = "Tail",

        includeJoints=["Tail 1"],
        excludeJoints=[],
        parent="modelRoot")

        self.loadAnims({"Idle":"plainshound-Idle.egg"},partName = "Body")
        self.loadAnims({"TailWag":"plainshound-TailWag.egg"},partName = "Tail")
        self.reparentTo(render)
        self.loop("Idle",partName = "Body")
        self.loop("TailWag",partName = "Tail")

Can you see the problem? (Thanks for being so patient and helpful in both my threads.:slight_smile:)

Hmm, I’m not sure. Try not specifying the partName parameter on the loadAnims() call, since the animation should load on the whole actor (you’re just going to play it on a subpart).

If that doesn’t make a difference, then maybe something’s wrong with the tail animation? What happens if you play just the tail animation? What if you play the tail animation on the whole body?

David

Ah, I bet that was it: you shouldn’t specify a partName when you’re loading the animation. See, you have loadAnims twice for the Idle animation, once without a partName–so that’s why Idle works.

Since the animation is designed with the entire skeleton of your Actor, it’s correct to load it onto the entire skeleton of the Actor–not just a subpart. Loading the animation onto a subpart only makes sense if the animation was designed just for that one part of the skeleton.

David

You were right about not needing to specify part names when loading the anims. However the subpart function is not working.

My idle animation does not animate the tail or jaw at all so I tried altering it so it does. I then loaded this altered animation and tried playing it on the “Body” subpart which excludes the tail and jaw but it still played the entire animation on all parts.

I think there is something wrong with my subpart code.

self.makeSubpart(
        partName = "Body",

        includeJoints = ["Center"],

        excludeJoints = ["Jaw","Tail 1"])

You must not be including/excluding the right joints. Maybe the tail hierarchy is not under a joint named “Tail 1”.

Try actor.listJoints(), to show the actual hierarchy of joints.

David

AAAHHHAAAA! I see! When I exported the model the spaces in the joint names were replaced with underscores! Hopefully I can now fix it! Thanks! :smiley::D:D

Edit : Yep it worked!

s165.photobucket.com/albums/u60/ … dfixed.flv

Thanks so much.