'2014/01'에 해당되는 글 185건

  1. 2014.01.28 폭파 불꽃 관련 파티클 이미지
  2. 2014.01.28 유니티의 오브젝트 크기, 위치, 색 설정하기
  3. 2014.01.28 유니티 WorldToScreenPoint를 사용하여 좌우 이동을 제한하는 스크립트
  4. 2014.01.28 유니티 오브젝트 키보드로 움직이기
  5. 2014.01.28 배경화면 스크롤 방법
  6. 2014.01.28 제트기 뒤 분화구 파티클 패키지 파일
  7. 2014.01.28 유니티 파티클 관련 속성 값 (Elipsoid Particle Emitter, Particle Animator, Particle Renderer)
  8. 2014.01.28 3D 오브젝트 파일 콜라이더 생성 Generate Colliders
  9. 2014.01.28 ScreenToWorldPoint 사용시
  10. 2014.01.28 유니티 카메라 관련 좌표값 변경 스크립트들 (1)

폭파 불꽃 관련 파티클 이미지

|


Explision.unitypackage


Trackback 0 And Comment 0

유니티의 오브젝트 크기, 위치, 색 설정하기

|


오브젝트의 크기는 localScale 속성으로 설정합니다.

오브젝트의 색상은(Red, Green, Blue, Alpha)로 설정하며, 각각 0~1 사이의 값으로 지정합니다.(메트리얼이 존재해야됩니다.)

오브젝트의 위치는 position 속성으로 설정합니다.





Transform.localScale

Vector3 localScale;
Description

The scale of the transform relative to the parent.

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour {
    void Example() {
        transform.localScale += new Vector3(0.1F, 0, 0);
    }
}




Trackback 0 And Comment 0

유니티 WorldToScreenPoint를 사용하여 좌우 이동을 제한하는 스크립트

|

키보드로 오브젝트를 이동시 좌우나 앞으로의 이동을 화면 안으로 제한하고 싶을 경우 쓰는 스크립트





Camera.main.WorldToScreenPoint함수의
Camera.main의 의미는 태그가 mainCamera로 설정된 카메라를 의미합니다.
메인카메라를 기준으로 하는 월드 좌표를 스크린 좌표로 변행해주는 함수 입니다.
if문에서는 왼쪽으로 이동시(key < 0 ) 위치를 제한( pos.x > 0) 해주고 오른쪽으로 이동시(key > 0 ) 위치를 제한(pos.x < Screen.width)해주고 있습니다.

이와 같이 오브젝트의 위치를 스크린 좌표로 변환하면 화면 크기에 상관없게 오브젝트의 위치를 제한 할 수 있습니다.




Camera.WorldToScreenPoint


Vector3 WorldToScreenPoint(Vector3 position);
Description

Transforms position from world space into screen space.

Screenspace is defined in pixels. The bottom-left of the screen is (0,0); the right-top is (pixelWidth,pixelHeight). The z position is in world units from the camera.
using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour {
    public Transform target;
    void Update() {
        Vector3 screenPos = camera.WorldToScreenPoint(target.position);
        print("target is " + screenPos.x + " pixels from the left");
    }
}


Trackback 0 And Comment 0

유니티 오브젝트 키보드로 움직이기

|
 
float amtMove = speed * Time.smoothDeltaTime; 는 오브젝트가 이동할시 프레임의 영향을 받지 않도록 일정한 속도로 움직이기 위해 설정된 값입니다. 

float key = Input.GetAxis("Horizontal");는 유니티 내의 Input관련 Horizontal로 정의된 값입니다. 키보드의 좌우 키를 누르거나 a d 키를 누를시 발동됩니다. 값은 -1~1사이 값입니다. 

transform.Translate(Vector3.right * amtMove * key , Space.World); 은 물체의 이동을 담당하는 함수입니다. Space.World는 월드 좌표 기준으로 이동한다는 의미입니다.



Trackback 0 And Comment 0

배경화면 스크롤 방법

|

스크롤방법

1. 오브젝트를 직접 이동하는 방법(Transform 사용)

2. 오브젝트의 메트리얼의 Offset 값을 이동하는 방법


2번의 방법이 구현이 간단함.

배경이 지속적으로 변하는 게 아니라면 2번의 방법으로 구현하는게 좋은거 같습니다.

아래는 종 방향으로 스크롤 되는 예제입니다.





횡방향인 경우에는 

로 하면 되겠죠?


메트리얼의 Offset은 ViewPort 좌표계를 사용합니다 0~1 인 상대좌표계이죠.

만약에 1이상인 경우에는 정수 부분을 무시해 버립니다. 그래서 위의 스크립트가 정상 작동 하는 것이죠.


Trackback 0 And Comment 0

제트기 뒤 분화구 파티클 패키지 파일

|


JetFire.unitypackage


Trackback 0 And Comment 0

유니티 파티클 관련 속성 값 (Elipsoid Particle Emitter, Particle Animator, Particle Renderer)

|

유니티의 파티클 관련 속성 값




Properties

EmitIf enabled, the emitter will emit particles.
Min Size각 입자의 최소 크기.
Max Size

각 입자의 최대 크기.

Min Energy입자의 초단위 최소 수명.
Max Energy

입자의 초단위 최대 수명.

Min Emission매초 만드는 입자의 최소 수.
Max Emission

매초 만드는 입자의 최대 수.

World Velocity

월드 기준 입자의 확산 방향 및 속도.

Local Velocity로컬 기준 입자의 확산 방향 및 속도.
Rnd Velocity

입자의 확상 방향 및 속도 랜덤 값.

Emitter Velocity ScaleThe amount of the emitter's speed that the particles inherit.
Tangent VelocityThe starting speed of particles along X, Y, and Z, across the Emitter's surface.
Angular VelocityThe angular velocity of new particles in degrees per second.
Rnd Angular VelocityA random angular velocity modifier for new particles.
Rnd RotationIf enabled, the particles will be spawned with random rotations.
Simulate In World Space이동시 궤적 표시 금지.
One ShotIf enabled, the particle numbers specified by min & max emission is spawned all at once. If disabled, the particles are generated in a long stream.
Ellipsoid

입자 생성 범위.

MinEmitterRangeDetermines an empty area in the center of the sphere - use this to make particles appear on the edge of the sphere.


Properties

Does Animate ColorIf enabled, particles cycle their color over their lifetime.
Color Animation5가지의 생상에 따라 입자의 색상이 변화됨.
World Rotation AxisAn optional world-space axis the particles rotate around. Use this to make advanced spell effects or give caustic bubbles some life.
Local Rotation AxisAn optional local-space axis the particles rotate around. Use this to make advanced spell effects or give caustic bubbles some life.
Size GrowUse this to make particles grow in size over their lifetime. As randomized forces will spread your particles out, it is often nice to make them grow in size so they don't fall apart. Use this to make smoke rise upwards, to simulate wind, etc.
Rnd ForceA random force added to particles every frame. Use this to make smoke become more alive.
ForceThe force being applied every frame to the particles, measure relative to the world.
DampingHow much particles are slowed every frame. A value of 1 gives no damping, while less makes them slow down.
AutodestructIf enabled, the GameObject attached to the Particle Animator will be destroyed when all particles disappear.



Properties

Cast ShadowsIf enabled, allows object to cast shadows.
Receive ShadowsIf enabled, allows object to receive shadows.
MaterialsReference to a list of Materials that will be displayed in the position of each individual particle.
Use Light ProbesIf enabled and baked light probes are present in the scene, an interpolated light probe.
Light Probe AnchorIf set, Renderer will use this Transform's position to find the interpolated light probe.
Camera Velocity ScaleThe amount of stretching that is applied to the Particles based on Camera movement.
Stretch ParticlesDetermines how the particles are rendered.
BillboardThe particles are rendered as if facing the camera.
StretchedThe particles are facing the direction they are moving.
SortedBillboardThe particles are sorted by depth. Use this when using a blending material.
VerticalBillboardAll particles are aligned flat along the X/Z axes.
HorizontalBillboardAll particles are aligned flat along the X/Y axes.
Length ScaleIf Stretch Particles is set to Stretched, this value determines how long the particles are in their direction of motion.
Velocity ScaleIf Stretch Particles is set to Stretched, this value determines the rate at which particles will be stretched, based on their movement speed.
UV AnimationIf either of these are set, the UV coordinates of the particles will be generated for use with a tile animated texture. See the section on Animated Textures below.
X TileNumber of frames located across the X axis.
Y TileNumber of frames located across the Y axis.
CyclesHow many times to loop the animation sequence.


Trackback 1 And Comment 0

3D 오브젝트 파일 콜라이더 생성 Generate Colliders

|

Generate Colliders 항목을 설정하면 오브젝트에 콜라이더가 만들어진다.

이 옵션으로 콜라이더를 만들 수 있는 것은 오브젝트가 255개 이내의 정점으로 이루어진 경우이다.

그 이상은 콜라이더를 만들수 없으니 주의(로우 폴리곤 모델은 이런식으로 만들어도 좋을듯)



Trackback 0 And Comment 0

ScreenToWorldPoint 사용시

|
  1. // Forum code warning
  2.  
  3.    var zdepth : float;
  4.    var newVector : vector3;
  5.  
  6. function myfunction () {
  7.  
  8. // Retrieve mouse position
  9.  
  10.    var x = Input.mousePosition.x;
  11.    var y = Input.mousePosition.y;
  12.  
  13.  
  14. newVector = Camera.main.ScreenToWorldPoint (Vector3 (x, y, zdepth));
  15.  
  16. }


카메라와 유니티의 오브젝트간의 Z값은 반드시 입력해 주어야 된다.

Input.mousePosition은 Vector2 값이고 z값은 항상 0이 입력됩니다.

그래서 입력하지 않을 시 월드 좌표는 항상 카메라의 좌표가 됩니다.


Trackback 0 And Comment 0

유니티 카메라 관련 좌표값 변경 스크립트들

|


WorldToScreenPoint

position을 월드 공간에서 화면 공간으로 변경시킵니다.

WorldToViewportPoint

position을 월드 공간에서 뷰포트 공간으로 변경시킵니다.

ViewportToWorldPoint

position을 뷰포트 공간에서 월드 공간으로 변경시킵니다.

ScreenToWorldPoint

position을 화면 공간에서 월드 공간으로 변경시킵니다.

ScreenToViewportPoint

position을 화면 공간에서 뷰포트 공간으로 변경시킵니다.

ViewportToScreenPoint

position을 뷰포트 공간에서 화면 공간으로 변경시킵니다.

ViewportPointToRay

카메라에서 시작된 뷰포트 지점을 지나는 광선을 반환합니다.

ScreenPointToRay

카메라에서 시작된 화면 지점을 지나는 광선을 반환합니다.



월드 좌표

- 오브젝트의 위치를 나타내는 좌표계로, 화면의 중심을 원점(0,0,0)으로 하는 3차원 상대좌표계입니다.

 월드 좌표계는 게임 화면을 투영하는 카메라의 위치와 회전 상태에 따라 달라지므로 반드시 화면의 중심이 원점이 되는것은 아닙니다.

화면 좌표(스크린좌표)

-스크린 좌표계는 단말기의 화면 좌표계로, 화면의 왼쪽 아래를 원점으로 하는 평면 절대좌표계입니다.

마우스 클릭이나 터치는 스크린 좌표계를 이용해서 처리합니다. 이 좌표계는 카메라의 위치나 각도와 상관없이 일정합니다.

뷰 포트 좌표

- 뷰 포트 좌표계는 화면에 글자나 2D 이미지를 표시하기 위한 좌표계로, 화면의 왼쪽 아래를 (0,0) 오른쪽 위를 (1, 1)로 하는 평면 상대 좌표계입니다.


Trackback 0 And Comment 1
  1. 2015.02.13 12:57 address edit & del reply

    비밀댓글입니다

prev | 1 | 2 | 3 | 4 | 5 | 6 | ··· | 19 | next