- 最后登录
- 2014-10-23
- 注册时间
- 2011-7-19
- 阅读权限
- 90
- 积分
- 81303
- 纳金币
- -1
- 精华
- 11
|
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. |
|