using UnityEngine;

using System.Collections;


public class TestPath : MonoBehaviour {

public Transform[] Path;

public float duration = 0.02f;

float percent = 0;

float startTime;

// Use this for initialization

void Start () {

startTime = Time.time;

/* put on path

Vector3[] points = new Vector3[Path.Length];

for(int i = 0; i < Path.Length; i++){

points[i] = Path[i].position;

}

*/

}

// Update is called once per frame

void Update () {

//percent = Mathf.Clamp01(Time.time - startTime) / duration;

percent = (Time.time - startTime) / duration;

iTween.PutOnPath(gameObject, Path, percent % 1);

Vector3 next = iTween.PointOnPath(Path, (percent + 0.1f) % 1);

//transform.LookAt(next);

Vector3 forward = next - transform.position;

transform.rotation = Quaternion.LookRotation(forward);

}

}


TestShake.cs 흔들어 주세요..


using UnityEngine;

using System.Collections;


public class TestPath : MonoBehaviour {

public Transform[] Path;

public float duration = 0.02f;

float percent = 0;

float startTime;

// Use this for initialization

void Start () {

startTime = Time.time;

/* put on path

Vector3[] points = new Vector3[Path.Length];

for(int i = 0; i < Path.Length; i++){

points[i] = Path[i].position;

}

*/

}

// Update is called once per frame

void Update () {

//percent = Mathf.Clamp01(Time.time - startTime) / duration;

percent = (Time.time - startTime) / duration;

iTween.PutOnPath(gameObject, Path, percent % 1);

Vector3 next = iTween.PointOnPath(Path, (percent + 0.1f) % 1);

//transform.LookAt(next);

Vector3 forward = next - transform.position;

transform.rotation = Quaternion.LookRotation(forward);

}

}


TestTween.cs 좌우로 흔들고 마지막에 크게.

using UnityEngine;

using System.Collections;


public class TestTween : MonoBehaviour {

bool isForward;

void Update () {

if(Input.GetMouseButton(0)){

if(isForward){

iTween.MoveTo(gameObject, new Vector3(3, 0, 0), 1.0f);

}

else{

//1)

//iTween.MoveTo(gameObject, new Vector3(-3, 0, 0), 1.0f);

//2)

//iTween.MoveTo(gameObject, iTween.Hash("x", -3, "easyType", "easeInCirc" , "time", 1.0f));

//3)

Hashtable table = new Hashtable();

table.Add("x", -3);

table.Add("easyType", iTween.EaseType.easeInElastic);

table.Add("time", 1.0f);

table.Add ("oncompletetarget", gameObject);

table.Add("oncomplete", "OnCompleteMove");

iTween.MoveTo(gameObject, table);

}

isForward = !isForward;

}

}

void OnCompleteMove(){

iTween.PunchScale(gameObject,1.5f * Vector3.one, 0.5f);

}

}



'Computer Language > 유니티' 카테고리의 다른 글

캐릭터,리그 ,애니메이터  (0) 2014.07.21
파티클 1번과 2번 2번을 주로 애용  (0) 2014.07.21
코루틴 예제  (0) 2014.07.01
하스스톤 디딤돌  (0) 2014.07.01
SkinnedMeshRenderer  (0) 2014.06.27

+ Recent posts