Game Development Reference
In-Depth Information
Lastly, change the shader the material uses to the
Transparent/Diffuse
shader by clicking
on the dropdown next to the
Shader
property of the
BloodSplatter
material, and then
navigate to
Transparent
|
Diffuse
.
Your material should now look like the following screenshot:
Restructuring the Goblin prefab
Now, because of the way the 2D animation system works, animating child objects from a
parent is fine; animating the child of child objects does not work, and also animating both
the parent and the child does not work as well. Basically, the transforms and parentage do
not play nice together.
This isn't a big issue; it just means you need to plan ahead more when you create objects
that will have multiple sprites or supporting objects that will all interact on the same anim-
ation.
To start off, perform the following steps:
1. Create a new and empty game object in the scene called
GoblinEnemy
.
2. Drag the existing
Goblin
prefab from
Assets\Prefabs\Characters
on to
the scene as a child of the new and empty game object (so we can reuse it); be
sure to reset the transform on the new child.
3. Delete the old prefab; we don't need it any more.
4. Remove the
Animator
,
EnemyController
, and
Box Collider 2D
scripts from the old
Goblin
prefab and add them on to the new and empty game
object called
GoblinEnemy
, setting them up as before. There are some com-