if (Input.GetButtonDown("Fire1"))
{
//클릭시 실행
//print("fire1");
//RayCast 로 충돌처리
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray, out hit, Mathf.Infinity))
{
print("raycast hit!");
Debug.DrawRay(ray.origin, ray.direction * 10f, Color.red, 5f);
}
}
ray.origin = 시작위치
ray.direction * 10f = 방향
Color.red = 디버그 라인 색깔
5f = 유지시간
'잡다한것들전부 > C#' 카테고리의 다른 글
| 유니티 c# RayCast 디버그 방법(눈으로 디버그라인을 그리는방법) (0) | 2014.01.19 |
|---|---|
| [펌]C# 델리게이트 및 이벤트 함수 (1) | 2014.01.13 |
| [queue] Queue 관련 함수 (Dequeue, Enqueue, Peek) (0) | 2014.01.12 |
| C# 동영상 강의 모은 곳 사이트 주소 (0) | 2014.01.04 |
| c# delegate (0) | 2013.12.30 |
| c# 제네릭 (0) | 2013.12.30 |
이 책이 얼마나 좋은지에 대해서 더 떠들어봤자 입만 아플 것이고(아니, 손가락이 아프겠군요), 번역서에 서문으로 적은 내용을 일부 인용하는 것으로 이 책의 소개를 대신할까 합니다.
정말 좋은 책이라고 c# 을 하시는 분들은 많이 추천해 주시더라고요.
뭐 가장 큰 단점은 번역이라고 할정도로 책 내용은 좋다.
천천히 읽어봅시다.
자꾸 책만 사날리는게 아닌가 싶기도 하지만 c# 책은 한권도 사지 않아서 일단 질러놨습니다.
'보고싶은책' 카테고리의 다른 글
| php와 mysql 관련 사고 싶은 책 (0) | 2014.10.05 |
|---|---|
| 사고 싶은 책 (0) | 2014.08.21 |
| c# 기본서 추천(c# IN DEPTH) (0) | 2014.01.19 |
| 열혈강의 cocos2d-x (0) | 2014.01.16 |
| 안드로이드 NDK 책 (0) | 2014.01.15 |
| “Game Programming Gems 1권 – 3.3 A* 길찾기 알고리즘의 기초” (0) | 2014.01.14 |
Animation Parameters
Animation Parameters are variables that are defined within the animation system but can also be accessed and assigned values from scripts. For example, the value of a parameter can be updated by an animation curve and then accessed from a script so that, say, the pitch of a sound effect can be varied as if it were a piece of animation. Likewise, a script can set parameter values to be picked up by Mecanim. For example, a script can set a parameter to control a Blend Tree.
Default parameter values can be set up using the Parameters widget in the bottom left corner of the Animator window. They can be of four basic types:
- Vector - a point in space
- Int - an integer (whole number)
- Float - a number with a fractional part
- Bool - true or false value

Parameters can be assigned values from a script using functions in the Animator class: SetFloat, SetInt, and SetBool.
Here's an example of a script that modifies parameters based on user input
using UnityEngine;
using System.Collections;
public class AvatarCtrl : MonoBehaviour {
protected Animator animator;
public float DirectionDampTime = .25f;
void Start ()
{
animator = GetComponent<Animator>();
}
void Update ()
{
if(animator)
{
//get the current state
AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0);
//if we're in "Run" mode, respond to input for jump, and set the Jump parameter accordingly.
if(stateInfo.nameHash == Animator.StringToHash("Base Layer.RunBT"))
{
if(Input.GetButton("Fire1"))
animator.SetBool("Jump", true );
}
else
{
animator.SetBool("Jump", false);
}
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
//set event parameters based on user input
animator.SetFloat("Speed", h*h+v*v);
animator.SetFloat("Direction", h, DirectionDampTime, Time.deltaTime);
}
}
}'잡다한것들전부 > 팁' 카테고리의 다른 글
| 레벨 단위 기획 (0) | 2014.01.21 |
|---|---|
| 유니티 스크립트 에디터ㄱ (0) | 2014.01.21 |
| Animation Parameters (0) | 2014.01.18 |
| [펌] 유니티 디바이스 화면에 디버깅 콘솔 찍기 (0) | 2014.01.16 |
| [펌] 유니티3D Conditional Attribute 사용 (0) | 2014.01.16 |
| [펌] 유니티 엔진 - 텍스트 파일을 이용하여 에셋 번들 한꺼번에 생성 하기 (0) | 2014.01.16 |


