일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- Cookie
- 웹게임
- model1
- CSS
- Servlet
- SQL
- JSP
- jQuery
- AWS
- tiles.xml
- docker
- RDS
- JavaScript
- HTML
- 웹소켓
- EC2
- 암호화
- 도커
- 비트코인
- 배포
- phaser
- Ajax
- Spring
- 알고리즘
- autowired
- websocket
- PL/SQL
- express
- 블록체인
- node.js
- Today
- Total
記錄
Roll a ball -1 본문
Rigidbody
Description
Control of an object's position through physics simulation.
물리 시뮬레이션을 통해서 object의 위치를 제어하는 컴포넌트.
Adding a Rigidbody component to an object will put its motion under the control of Unity's physics engine. Even without adding any code, a Rigidbody object will be pulled downward by gravity and will react to collisions with incoming objects if the right Collider component is also present.
Rigibody component를 object에 추가함으로써 유니티의 물리 엔진으로 object의 모션을 제어할 수 있도록 한다. 이 컴포넌트를 추가만 하면 코드를 한 줄도 쓰지 않아도 중력 법칙이 적용되고 다른 object와의 충돌효과도 나타난다.
The Rigidbody also has a scripting API that lets you apply forces to the object and control it in a physically realistic way. For example, a car's behaviour can be specified in terms of the forces applied by the wheels. Given this information, the physics engine can handle most other aspects of the car's motion, so it will accelerate realistically and respond correctly to collisions.
Rigidbody의 API는 object에 force가 작용하게끔 해주고 조금 더 현실적으로 물리 법칙을 제어할 수 있도록 도와준다. 예를 들어서 자동차의 가장 특징적인 힘인 바퀴에 작용하는 힘도 물리 엔진이 이런 특성을 이해하고 좀 더 현실적으로 충돌에 반응 할 수 있도록 해준다.
In a script, the FixedUpdate function is recommended as the place to apply forces and change Rigidbody settings (as opposed to Update, which is used for most other frame update tasks). The reason for this is that physics updates are carried out in measured time steps that don't coincide with the frame update. FixedUpdate is called immediately before each physics update and so any changes made there will be processed directly.
스크립트에서는 FixedUpdate 함수를 사용할 것을 추천한다. Rigidbody setting을 바꾸고 물리적인 힘을 적용하기 위해서이다. Update 함수가 아니라 FixedUpdate 함수가 사용되는 이유는 물리적 변경은 동시에 일어나는 것이 아니라 정해진 time steps의 frame update에 일어나기 때문이다. FixedUpdate 함수는 물리적 변경이 일어나기 전에 call 되어서 어떠한 변경이든 즉각적으로 반영되도록 도와준다.
(쉽게 말해서 Update는 매 프레임이 계속 갱신 되면서 반영되는 것이고 FixedUpdate는 예정된 프레임에, 반영의 필요가 발생된 시점에 call 되기 때문에 자원의 활용 측면에서 더 효율적이라서 FixedUpdate를 쓴다는 의미로 예상된다)
Rigidbody.AddForce
public void AddForce(Vector3 force, ForceMode mode = ForceMode.Force);
Description
Adds a force to the Rigidbody.
Rigidbody에 force를 반영한다.
Force is applied continuously along the direction of the force vector. Specifying the ForceMode mode allows the type of force to be changed to an Acceleration, Impulse or Velocity Change.
Force는 force vector의 방향을 따라 지속적으로 작용한다. ForceMode를 명확히 파악하고 반영하는 것은 충돌이나 속도변화, 가속이 가능하게끔 해준다.
Force can be applied only to an active Rigidbody. If a GameObject is inactive, AddForce has no effect.
Force는 오직 Rigidbody가 활성화 된 경우에만 작동하고 Rigidebody가 inactive인 경우에는 AddForce는 아무런 효과가 없다.
Input.GetAxis
public static float GetAxis(string axisName);
Description
Returns the value of the virtual axis identified by axisName.
axisName에 의해 확립된 virtual axis 값을 반환한다
The value will be in the range -1...1 for keyboard and joystick input. If the axis is setup to be delta mouse movement, the mouse delta is multiplied by the axis sensitivity and the range is not -1...1.
'Game > Unity' 카테고리의 다른 글
Roll a ball -2 (0) | 2018.01.08 |
---|