1 분 소요

image

image

  • cannon은 empty, body는 cube, luncher는 empty, po는 cyllinder / collider 다 없애줌
  • firepos는 empty 발사체가 나가는 실질적 위치! LancherControl script 넣어줌
  • cannonball은 empty, sphere collider 추가, rigidbody 추가, CannonBall script 추가 /
  • model은 sphere
  • Assets에 mCannonBall materal 추가 , color 선택 → model에 입혀줌(화면으로 드래그)
  • CannonBall을 Assets창에 드래그 하고 비활성화해줌
  • CannonBall을 Firepos의 obj cannonball에 드래그

주의!! plane의 mesh collider에서 convex체크해줘야 물리접촉 가능

-CannonBall-

    // Start is called before the first frame update
    public float _addForce = 1000;
    Rigidbody _rgbd3D;   
    void Awake()
    {
        _rgbd3D = GetComponent<Rigidbody>();
        _rgbd3D.AddForce(transform.forward * _addForce);
        Destroy(gameObject, 5);
    }
  • 게임오브젝트의 rigidbody 컴퍼넌트를 불러옴
  • AddForce는 물체에 가하는 힘 / 게임오브젝트(cannonball)의 방향으로 가하도록 설정
  • 5초후 없어지도록 destory(대상,시간) 설정

-Launcher Script-

    public GameObject _objCannonball;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Jump"))
        {
            Instantiate(_objCannonball, transform.position, transform.rotation) ;
            
        }
    }

  • GameObjec _objCannonball로 CannonBall을 가져옴
  • 만약 키보드의 점프키(space bar)를 눌렀을 경우 cannonball을 cannonbal의 방향과 회전각 그대로 나가게 해줌 → Instantiate

Trail Renderer

image

  • TrailRenderer는 검광이나 우주선 분사구의 이펙트를 대신해서도 많이 쓴다.

image

  • 발사체에 여러 개의 면들이 생기면서 저 면들이 Time에 적혀있는 시간에 따라 없어지는거임

image

image

  • Time을 1로하면 발사체를 따라가는것 처럼 보임

  • Width 창에서 발사체꼬리에 대한 각도, 모습 등을 직접 설정 할 수 있음

image

  • 발사체꼬리는 materials에서 설정해야하는데 기본이 none임. assets에서 material만들어주고, 드래그 해줌
  • matertial의 shader에서 additive 눌러주고 selec texture에 원하는 이미지를 클릭 (그냥해도되는데?;;)
  • cannonball 오브젝트로 돌아와서 color변경 . 그라데이션 형식임

image

주의!!! 다했으면 overrides에서 적용을 해줘야함!!!(clone들에영향)

댓글남기기