[런게임] 유니티 3D로 러너 게임 만들기 - 길의 종류

|

길의 종류

게임을 좀더 재미있게 하기 위해서 두가지 길을 더 추가 하겠습니다. 한가지 길은 Runner이 길 위에 있을시 속도가 느려지는 것이고 나머지 하나는 속도가 빨라지는 것 입니다. 우리는 두가지 physic materials을 만들고 두가지 색상을 만듭니다 그리고 길에 랜덤하게 이것을 사용합니다. 

Platform Regular PMat 2번 복사합니다. 이름을 Platform Slowdown PMat, 그리고 Platform Speedup PMat이라고 설정합니다. 또한 비슷한 방식으로 Platform Regular Mat를 두번 복제하고 이름을 지읍시다. friction값을 0.15 그리고 0으로 설정하고, 색상은  (255, 255, 0) 그리고 (60, 130, 255)으로 설정합니다.

slowdown physic material speedup physic material 
slowdown material speedup material 
hierarchy
Slowdown and speedup platforms.
우리는 이제  PlatformManager 를 수정할것입니다. 우리는 두가지 배열을 더해서 랜덤하게 위에서 설정한 깂들을 사용할 것입니다.
	public Material[] materials;
	public PhysicMaterial[] physicMaterials;

	private void Recycle () {
		Vector3 scale = new Vector3(
			Random.Range(minSize.x, maxSize.x),
			Random.Range(minSize.y, maxSize.y),
			Random.Range(minSize.z, maxSize.z));

		Vector3 position = nextPosition;
		position.x += scale.x * 0.5f;
		position.y += scale.y * 0.5f;

		Transform o = objectQueue.Dequeue();
		o.localScale = scale;
		o.localPosition = position;
		int materialIndex = Random.Range(0, materials.Length);
		o.renderer.material = materials[materialIndex];
		o.collider.material = physicMaterials[materialIndex];
		objectQueue.Enqueue(o);

		nextPosition += new Vector3(
			Random.Range(minGap.x, maxGap.x) + scale.x,
			Random.Range(minGap.y, maxGap.y),
			Random.Range(minGap.z, maxGap.z));

		if(nextPosition.y < minY){
			nextPosition.y = minY + maxGap.y;
		}
		else if(nextPosition.y > maxY){
			nextPosition.y = maxY - maxGap.y;
		}
	}
}
위에서 설정한 값을들 Platform Manager 에 할당합시다. 우리는 어떤한 길 유형을 더하려고 할 경우, 단순히 여러 번 이렇게 드래그해서 더하면 됩니다. 아래와 같이 설정하면 일반 속성같은 경우 50퍼 센트 확률로 발생되고 나머지 속성같은경우 25퍼선테 확률로 발생됩니다.
settingsgame
Platform variety.


Trackback 0 And Comment 0