• [Unreal 게시판] timer가 0이 되면 Game Over가 되게하는 방법2014.09.03 PM 01:58

게시물 주소 FONT글자 작게하기 글자 키우기

Question>

게임중 타이머를 줘서
타이머가 0되면 게임 오버가 되게하고싶은데
알려주실수있나요?

아이템을 먹으면 타이머가 일정이상 되돌아가고 그렇게 할수있나요?

-------------------------------------------------------------

Answer>

아래와 같은 방법들이 가능합니다.



1>unreal engine 4 C++로 timer 다루는 방법.
아래 link를 참고하시기 바랍니다.^^

https://docs.unrealengine.com/latest/KOR/Programming/UnrealArchitecture/Timers/index.html
https://answers.unrealengine.com/questions/83344/set-timer-handlers.html

game이 시작되고 나서,
30초 뒤에 AYourPlayerController::ProcGameOver()라는 함수를 호출해서,
'Game Over'를 처리하고 싶으시다면..^^;;;;;

game이 시작될 때, 아래 source를 수행하면 됩니다.

GetWorldTimerManager().SetTimer( this, &AYourPlayerController::ProcGameOver, 30.0f, false );

'마지막 parameter'가 false인 이유는 1회성 timer이기 때문입니다.
( 만약에 '마지막 parameter'를 true로 한다면,
30초 간격으로 'Game Over'가 계속 처리됩니다. 이건 error라고 봐야 겠죠.^^;;;;;;; )



2>unreal engine 4에서 blue print의 'Set Timer'로 timer를 다루는 방법.
아래 link를 참고하시기 바랍니다.^^

https://answers.unrealengine.com/questions/45082/timer-for-toggle-visibility.html
(주의: 'Event Tick'을 중심으로 보시면 안되고, 'Set Timer'를 중심으로 보세요. ^^;;;)

사용 요령은 '1>'과 같습니다.^^



3>unreal engine 4에서 blue print의 'Event Tick'과 'Get Game Time in Seconds'를 이용하는 방법.
정석은 아니지만 아래와 같은 방법도 가능합니다.^^;;;;;

https://answers.unrealengine.com/questions/38567/timer-that-counts-up-and-stops-when-reaching-end-o.html

요약하면, tick으로 'Get Game Time in Seconds'을 계속 검사하다가,
님이 원하는 시간이 됐을 때, 'Game Over'를 처리하시면 됩니다.

'1>', '2>'에 비하면, 좀 무식한 방법(??!! ^^;;;;)이지만,
시간의 정확도는 '1>', '2>'보다 더 높습니다.^^



3가지 중에 마음에 드는 걸로 고르시기 바랍니다~ ^^

그리고,
'아이템을 먹으면 타이머가 일정이상 되돌아가고 그렇게 할수있나요?'라고 하셨는데,
item을 먹었을 때, 변수값을 원하시는대로 조정해서
'1>', '2>'의 SetTimer()를 다시 호출하시면 되고,
'3>'의 경우, 변수에 시간의 가감을 하셔서, 초기화하시면 됩니다.^^



P.S.
님이 class AActor나 class UWorld에 관계 없이
timer를 만들고 싶으시다면 아래 link를 참고하시기 바랍니다.^^

https://answers.unrealengine.com/questions/78591/create-a-timer-for-plugin-without-reference-to-uwo.html

위 방법은 windows에서만 먹히고요.
iOS는 Objective-C의 class NSTimer를 써야해서리, source가 훨씬 지저분해 집니다.@_@;;;;;



P.S.2
unreal engine 3(or UDK)의 경우, 아래 link들을 참고하시기 바랍니다.

unreal s!crip으로 하는 방법:
http://cafe.naver.com/igc123/243
http://cafe.daum.net/igc123/K3VE/186

kismet으로 하는 방법:
http://cafe.naver.com/igc123/117
http://cafe.daum.net/igc123/K3VE/88

parameter의 순서가 바뀌었을 뿐, 방법은 유사합니다.^^







Tag:
안기훈, Kee Hoon Ahn, 언리얼, Unreal, UDK, iPhone, iPad, app, 앱, iOS
댓글 : 0 개
친구글 비밀글 댓글 쓰기