내 목표 : 달팽이가 스스로 움직이는 것처럼 보이게하려면. 예 : 몇 초 동안 오른쪽으로 이동하고 몇 초 동안 왼쪽으로 이동하여 몇 초 동안 한 곳에 머물러보세요.Unity, C# | 메소드 간 대기 시간은 어떻게됩니까?
현재 상태 : 내가 WaitForSeconds
없이 WaitForSeconds
를 사용하려고 할 때 달팽이 내 달팽이
난 단지 시작했습니다 (이 정말 빨리 일을 제외)을 성공적으로 앞뒤로 방향을 변경 한 곳에서 여전히 앉아 어제 Unity와 C#을 배웠습니다. 모든 팁/제안은 원래의 질문에 있지 않더라도 많은 도움이 될 것입니다. 내가 도와 줄 수있는 다른 방법이 있다면 알려주십시오! :)
using UnityEngine;
using System.Collections;
public class SnailMove : MonoBehaviour {
void Start()
{
}
// Use this for initialization
void Update()
{
Waiting();
}
// Update is called once per frame
void Movement()
{
int direct = Random.Range(-1, 2);
if (direct == 1)
{
transform.Translate(Vector3.left * 1f * Time.deltaTime);
transform.eulerAngles = new Vector2(0,180);
}
if (direct == -1)
{
transform.Translate(Vector3.left * 1f * Time.deltaTime);
transform.eulerAngles = new Vector2(0,0);
}
}
IEnumerator Waiting()
{
Movement();
yield return new WaitForSeconds (5);
}
}
Omg. 나는 너를 너무 많이 사랑해! 이것은 완벽 해!! <3 – FireFoxxie