12 第1页 | 共2 页下一页
返回列表 发新帖
查看: 5366|回复: 12
打印 上一主题 下一主题

unity3d第三人称角色控制教程-3

[复制链接]

5552

主题

2

听众

8万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
11

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2011-12-8 17:14:45 |只看该作者 |倒序浏览


In part 2 of our 3rd person character controller tutorial for Unity we set the input settings and the animation sequences for the player character, now we shall place the character into the scene and add the Character Controller object. We will also position the camera so that we can see the character from behind.


Place the Character

To place the character into the scene, drag it from the Project Panel into the scene view. When you do this the character will be in the scene and an entry will appear in the Hierarchy.
You will probably need to position the character, so grab the translate tool and with the character selected position it in the middle of the scene and make sure that its feet are touching the ground (but not going through the ground else the character will fall through).
You can use the gizmo in the top right of the viewport to switch between top down, side, front and perspective modes to make life easier. When the character is positioned it should look something like the screenshot below.



Apply a Character Controller Component



Now that the character is in the scene we need to apply a "Character Controller" component to it so that Unity knows that this object is a playable character, so with the character selected in the Hierarchy go to:
Component -> Physics -> Character Controller
When the prefab warning appears click "Add" to accept the change and continue. With the controller component added we need to scale the collision capsule so that it is the same size as the character and so that its positioned around the character.
In the inspector you will see the character controller settings when the character is selected, switching to front and side views you need to adjust the height and radius to match the character and the Center values so that the capsule is in the correct position.

So for our test character set the height to 1.85, radius to 0.4 and the Y center value to 0.93; if your using your own character the settings may be different.
The aim is to get the capsule to fit around the character as snugly as possible and to ensure the capsule does not poke through the terrain/ground; like pictured below:



Position the Camera



Now we will position the camera, so select the Main Camera in the Hierarchy and move it so that it is behind the character and rotate it slightly so its looking at the character from a slight angle.

If you play the game now you will see the character, with the idle cycle animating through. You however cannot move the character around, this is because we need to write a script to accept input from the player which will then manipulate that controller component and tell the character model to switch to different animation cycles. So in part 4 we will create the controller script.
由 u8 发表
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

315

主题

0

听众

1万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
10878
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

沙发
发表于 2011-12-9 09:11:39 |只看该作者
回复

使用道具 举报

1023

主题

3

听众

359

积分

设计实习生

Rank: 2

纳金币
335582
精华
0

最佳新人

板凳
发表于 2012-3-13 23:20:03 |只看该作者
你们都躲开,我来顶
回复

使用道具 举报

797

主题

1

听众

1万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
5568
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

地板
发表于 2012-3-16 19:43:30 |只看该作者

   
回复

使用道具 举报

   

671

主题

1

听众

3247

积分

中级设计师

Rank: 5Rank: 5

纳金币
324742
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

5#
发表于 2012-4-3 23:28:37 |只看该作者
水。。。
回复

使用道具 举报

tc    

5089

主题

1

听众

33万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

6#
发表于 2012-6-1 23:20:19 |只看该作者
顶!学习了!阅!
回复

使用道具 举报

462

主题

1

听众

31万

积分

首席设计师

Rank: 8Rank: 8

纳金币
2
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

7#
发表于 2012-6-2 23:25:34 |只看该作者
响应天帅号召,顶
回复

使用道具 举报

5969

主题

1

听众

39万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

8#
发表于 2012-8-6 23:51:19 |只看该作者
“再次路过……”我造一个-----特别路过
回复

使用道具 举报

1023

主题

3

听众

359

积分

设计实习生

Rank: 2

纳金币
335582
精华
0

最佳新人

9#
发表于 2012-9-24 23:27:31 |只看该作者
顶!学习了!阅!
回复

使用道具 举报

tc    

5089

主题

1

听众

33万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

10#
发表于 2012-10-4 23:22:45 |只看该作者
提醒猪猪,千万不能让你看见
回复

使用道具 举报

12 第1页 | 共2 页下一页
返回列表 发新帖
您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2025-7-17 21:50 , Processed in 0.067662 second(s), 32 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部