Why place the sprite renderer on the child (body)?

Hi,

I understood Rick’s point re: the importance of the animator and scripts existing on the same ‘parent’ game objects (so that if animation events are used, the animator and script can successfully communicate with one another).

What I still didn’t fully understand by the end of this lecture, however, was why a ‘child’/body game object (inc. sprite renderer) was needed at all?

If our lizard, for instance, just consisted of 1 x parent object (containing various components: inc. sprite renderer, animator, scripts, etc.) then we’d still have any animation events on this object working fine - and it would save us having to add an unnecessary ‘child’.

Basically, I’m not entirely sure what it adds by having the sprite renderer not on the parent when it would appear to allow for the same functionality in this project.

One theory I have - albeit I’m not particularly familiar with 3D bone-based animation - is that the parent/child relationship re: animations becomes more important with bone-based stuff? Is it just that the concept Rick’s teaching here is useful when it comes to more complex animations - even though it’s not totally needed in this project?

If anyone can explain, it would be much appreciated :slight_smile:

Many thanks.

You are touching upon very interesting point. When you use animator to animate sprites they animate in their position relative to the parent. This is not noticable when you scale or rotate BUT when you move the parts as part of the animation this literally breaks everything.

Let’s consider those 2 examples:

  1. You have a sprite renderer directly on the object with animator and it has no parent. As part of the walk animation you move the character from 0,0,0 to 0,1,0. What will happen? As soon as you start moving (does not matter where the character is) it will be teleported to 0,0,0 and them move to 0,1,0.

  2. You have a sprite renderer on a child object and animator on parent. The same story. This time however the child will be behaving as expected because it will move from 0,0,0 position in RELATION TO THE PARENT to 0,1,0 in RELATION TO THE PARENT :slight_smile:

Please let me know if that is clear. In the worst case scenario I can try to record a video showing the difference. Actually I think I do have as a part of one of my youtube videos :smiley:

Thank you for taking the time to explain, Piotr! Actually, if you have a link to the YouTube video where you demonstrate this, that would be v.helpful as I’m still not 100% sure I understand.

@ooh_777 , here you are:

Moderators, admins, could you please I am allowed to link videos to my youtube channel? I checked the rules and it seems to me that this should be ok?

Thanks so much! I’ll watch this now :slight_smile:

Privacy & Terms