'유니티'에 해당되는 글 227건

  1. 2014.01.28 유니티 오브젝트 키보드로 움직이기
  2. 2014.01.28 배경화면 스크롤 방법
  3. 2014.01.28 제트기 뒤 분화구 파티클 패키지 파일
  4. 2014.01.28 유니티 파티클 관련 속성 값 (Elipsoid Particle Emitter, Particle Animator, Particle Renderer)
  5. 2014.01.28 3D 오브젝트 파일 콜라이더 생성 Generate Colliders
  6. 2014.01.28 ScreenToWorldPoint 사용시
  7. 2014.01.28 유니티 카메라 관련 좌표값 변경 스크립트들 (1)
  8. 2014.01.27 유니티 특정 시간마다 호출되는 함수 만들기.
  9. 2014.01.27 유니티 RayCast 관련 - 마우스 클릭으로 판별 - 4.3 2D 용 전환
  10. 2014.01.27 TTclock

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

|
 
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

    비밀댓글입니다

유니티 특정 시간마다 호출되는 함수 만들기.

|

특정 시간마다 호출되는 함수를 만들고 싶을수 있습니다.







유니티 내에 존재하는 함수도 있음

아래 함수는 특정시간 후 함수 호출 (반복호출시 끝에 Invoke("MoveMoles", 2.0f)) 를 넣어주면 계속해서 반복호출이 되겠죠?


아래처럼 코루틴을 사용하는 방법이 제일 일반 적인 방법이 아닐까 싶습니다.

아래코드는 CountTime이 무한 반복 됩니다.



Trackback 0 And Comment 0

유니티 RayCast 관련 - 마우스 클릭으로 판별 - 4.3 2D 용 전환

|


Unity 3D의 레이케스트를 사용해서 물체를 판별하는 방법(당연히 물체에 콜라이더 컴포넌트 적용 되야 됨)



  1.             RaycastHit hit = new RaycastHit();
  2.  
  3.        
  4.  
  5.             if (Physics.Raycast(ray.origin,ray.direction, out hit)) {
  6.                 hit.transform.gameObject.SendMessage("HandleInput");
  7.             }
  8. }


Unity 2D의 레이케스트를 사용해서 물체를 판별하는 방법(당연히 물체에 2D 콜라이더 컴포넌트 적용 되야 됨)


  1. {
  2.     RaycastHit2D hit = Physics2D.GetRayIntersection(ray,Mathf.Infinity);
  3.            
  4.     if(hit.collider != null && hit.collider.transform == thisTransform)
  5.         {
  6.                // raycast hit this gameobject
  7.          }
  8. }


아래 방법도 동일함


  1.  
  2. if(collider2D.OverLapPoint(mousePosition))
  3. {
  4. //do great stuff
  5. }
  6.  
  7.  
  8. }


Trackback 0 And Comment 0

TTclock

|

TTclock


눈이 너무 아파서 50분 공부하고 10분 쉬고 이렇게 해야겠다.


Trackback 0 And Comment 0
prev | 1 | ··· | 17 | 18 | 19 | 20 | 21 | 22 | 23 | next