If you've sculpted some terrain (such as hills or cliffs) then you will notice that the character can walk up even a sheer vertical incline, which is impossible; so we want to prevent this. It is actually very easy to set a slope limiter to prevent the character walking up an incline of x degrees, because the character controller component we attached to the character has a slope limiter built in, its just got a very steep allowance at the moment.
1. Select the character in the Hierarchy
2. Under the character controller section in the Inspector look for "Slope Limit"
It has a default of 90 degrees, which is pretty steep, so lets change it to 40-50 degrees. Now if you havent done so already, sculpt some geometry onto your terrain and test it out, adjusting the slope limit until you feel its at a comfortable limit for your game.
Now in part 6 we shall be concluding our tutorial with a quick discussion on controllers and some final thoughts.
So you've completed the bulk of the 3rd person character controller tutorial, while it works pretty well its very basic and will want extending... which was kind of the point of this tutorial; to provide the bare bones; basic controller for you to extend for your games as opposed to bogging you down in game specific mechanics.
If you understood the code in the script you should be able to add more actions now, like if you have a punch animation how to read in a button press to play that animation and how to add some logic into the script; things like that.
This final section mentions some final thoughts.
Final Thoughts
Follower Cameras
While the follower camera works, you do need to consider camera collision; but to do that you need a grasp on other mechanics which are outside of the scope for this tutorial, we'll be adding an advanced camera control tutorial very soon so watch this space.
Reading Animation Time
Its useful to know how to read in the time of an animation for when you perform actions; its quite simple, this code will return the duration of an animation:
animationTime = animation["name_of_animation"].clip.length;
Applying Textures to your Character
We didn't cover how to apply textures to your character; this is quite simple and is the same for any model import. Import the textures individually, open the materials and apply the texture for each material in the Inspector.
由 u8 发表