Game Development Reference
In-Depth Information
Step 5. At this point the cloth cape object will be immensely huge.
Double-click on the Interactive Cloth object in the Hierarchy to
position the camera in the scene on its location. You will now need
to scale, rotate, and transform the cape such that it is in the same
position relative to the character shown in Figure 3.20 . If you haven't
moved the character, the correct cape transforms are also shown
in Figure 3.20 .
Step 6. With the cape in position, select the Interactive Cloth and add
one Attached Collider in the Inspector. Drag the main Hero object from
the Hierarchy onto the Collider variable as shown in Figure 3.20 . The cape
must intersect with the character's collider in order for it to stick to it. This
is the same principle used for hanging up the curtain in the warehouse
of Chapter Two.
Step 7. Play. The cape will be attached to the character's shoulders
and move when he moves.
Step 8. A final touch would be to add a shader with backface culling
turned off so that the cape is visible from both sides. The code for this is
similar to that used for the curtain in Chapter Two. However, one small
detail needs to be added to ensure that the cape casts a shadow. Create
a new shader in the Project and call it BackfaceOn. Open the file in
script editor by double-clicking on it and replace the code with ALL
of that in Listing 3.28 . The part shown in bold is the line needed
for shadows that would have been missing from the curtain shader
in Chapter Two.
Listing 3.28 A Backface on Shader, Which Casts Shadows
Shader "Backface On" {
Properties {
_Color ("Main Color", Color) = (1,1,1,0)
_SpecColor ("Spec Color", Color) = (1,1,1,1)
_Emission ("Emmisive Color", Color) = (0,0,0,0)
_Shininess ("Shininess", Range (0.01, 1)) = 0.7
_MainTex ("Base (RGB)", 2D) = "white" { }
}
SubShader {
Material {
Diffuse [_Color]
Ambient [_Color]
Shininess [_Shininess]
Specular [_SpecColor]
Emission [_Emission]
}
Lighting On
SeparateSpecular On
Search Nedrilad ::




Custom Search