[게임개발자] 레드핑
Godot Attack 만드는법 (2) 본문
이전 포스팅 https://allggame.tistory.com/24
Godot Attack 만드는법
https://www.youtube.com/watch?v=74y6zWZfQKk&t=1s&ab_channel=Bitlytic 상속보다 Component 를 제작해서 재사용성 높이기 와... 이강의를 보고 드디어 SOLID 원칙의 S 를 깨닫게 되었다. 왜 굳이 Single Responsibility 를 해야
allggame.tistory.com
에서 영상을 보아하니 , Attack.gd 가 필요했다.
참고자료는 https://www.youtube.com/watch?v=y3faMdIb2II&ab_channel=Bitlytic 영상에서 참고할 수 있다.
코드는 2줄로 줄여보았다.
Godot docs 에 찾아보니
보통 커스텀 변수 타입을 2가지 방식으로 만들수 있는데
첫번째는 상수 네임을 선언해서 미리 스크립트를 로드해서 사용하는법이다.
두번째는 class_name 을 선언해서 사용하는 방법이다.
class_name (예약어) 를 사용하면 스크립트에서 전역적으로 사용할수있는 , 특별한 이름을 부여시킬수있다.
결국 attack_damage 라는 변수를 다양한 스크립트에서 사용하기 위한 방법이라고 볼수있다.
내일 할 것: HealthComponent 손보기
참고사이트:
https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html
https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/static_typing.html
'일상 > 개발일상' 카테고리의 다른 글
Godot weapon GDscript (0) | 2023.10.14 |
---|---|
Godot hitboxComponent (0) | 2023.10.12 |
Godot Attack 만드는법 (0) | 2023.10.10 |
Godot player Player chasing 만들기 (0) | 2023.10.09 |
Godot Collision Layer 과 Mask 뜻. (0) | 2023.10.08 |