查看: 815|回复: 0
打印 上一主题 下一主题

小地图的制作代码(转)

[复制链接]
may    

8830

主题

81

听众

7万

积分

首席设计师

Rank: 8Rank: 8

纳金币
52352
精华
343

最佳新人 热心会员 灌水之王 活跃会员 突出贡献 荣誉管理 论坛元老

跳转到指定楼层
楼主
发表于 2013-4-28 20:39:52 |只看该作者 |倒序浏览
pstatus"> 本帖最后由 may 于 2013-4-28 20:56 编辑

After starting your Unity project:

1. Select GameObject -> Create Other -> Camera, rename it as you like it
创建一个相机,然后命名

2. Select Assets -> Create -> Javas cript, rename it to "OrbitCam" or something similar ("Minimaps cript", etc.), edit it
开一个新的JS脚本,命名为 Orbir Cam , 然后贴上以下的代码:

javas cript code:var target : Transform;

var damping = 6.0;

var smooth = true;function LateUpdate () {

  if (target) {

    if (smooth)

    {

      // Look at and dampen the rotation

      var rotation = Quaternion.LookRotation(target.position -transform.position);

      transform.rotation = Quaternion.Slerp(transform.rotation, rotation,Time.deltaTime * damping);

    }

    else

    {

      // Just lookat

        transform.LookAt(target);

    }

    transform.position.y = target.position.y + 90;

    transform.position.x = target.position.x;

    transform.position.z = target.position.z;

  }

}

function Start () {

  // Make the rigid body not change rotation

    if (rigidbody)

    rigidbody.freezeRotation = true;

}

3. Click the minimap camera you created earlier, then without clicking the s cript, drag the s cript onto the camera name
把写好的脚本拖曳到相机

4. Still having the minimap camera on, drag the target of the minimap (the character, car, whatever) onto the field Target
将角色拖曳到Target的栏位,最后再调整相机的XY,WH的画面大小即可

All is set. Remember that the Depth of the minimap camera should be above the Depth value of the Main Camera, or the minimap itself will be hidden behind the Main Camera view! Very important!

An example of minimap camera properties set:

Projection property can be set as either Perspective or Othographic, with Field of View also customised to your needs.

Normalized View Port Rect properties can be set as following:

X: 0.04 (0.54 for the second minimap if you use the splitscreen multiplayer))

Y: 0.04 (0.54 for the second minimap)

X and Y properties specify the position of the minimap on the screen.

W: 0.2

H: 0.2

W (width) and H (height) properties specify the size of the minimap. 0.2 means 20%. You can set them as you wish.


分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

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

GMT+8, 2025-8-3 04:43 , Processed in 0.097909 second(s), 28 queries .

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

© 2008-2019 Narkii Inc.

回顶部