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

创建光束效果详细步骤(下)

[复制链接]

5552

主题

2

听众

8万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
11

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

跳转到指定楼层
楼主
发表于 2012-2-20 13:43:24 |只看该作者 |倒序浏览


Asset Creation in Unity
1.Create a game object this will our Beam Container and name it “LightBeam”.

2.Create a plane name it “BeamPlane” Rotate this plane at x to 90 degrees. This will be our beam object. You can scale this plane as suitable for your beam area.

3.Remove the mesh collider, we don’t want stuck object to beam. Also  remove checks from Cast Shadows and Receive Shadows properties under Mesh Renderer

4.Drag the “BeamPlane” plane to  “LightBeam” object. This make plane child of LightBeam object.

5.Import that png file unity.

6.Create a material with Particles/Addictive shader. Drag this imported texture to “Particle Texture” channel. If you want more transparency with beam you can darken  the Tint Color.

7.Assign this texture to previously created plane.

8.Align the “LightBeam” object to your light source.




There you go, your light have beam.
Its not finished yet. If you move the camera you’ll see this beam will stand still. For realistic view, we’ve to face it to camera always.
To achieve that;
Create a new c# file named LookAtCameraYonly.cs and copy this codes in to ;
using UnityEngine;
using System.Collections;

public class LookAtCameraYonly : MonoBehaviour
{
    public Camera cameraToLookAt;
    void Update()
    {
        Vector3 v = cameraToLookAt.transform.position - transform.position;
        v.x = v.z = 0.0f;
        transform.LookAt(cameraToLookAt.transform.position - v);
    }
}


Drag and drop new created script to “LightBeam” gameobject.
We need to assign main camera to “Camera To Look At” propery of this script. So drag main camera and drop it to propertybox.
Now when you walk around, beam object turn to camera and it will look better.
Check out the result. I used Urban Props from asset store. (http://u3d.as/content/bi-ski-t/urban-props/1Rf)


You can move around using with arrow keys.
I hope you find the article useful.
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

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

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

GMT+8, 2024-11-14 01:14 , Processed in 0.284327 second(s), 33 queries .

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

© 2008-2019 Narkii Inc.

回顶部