250227

lililllilillll·2025년 2월 27일

개발 일지

목록 보기
95/350

✅ 오늘 한 일


  • Project BCA


🎮 Project BCA


Target offset correction

  • 기하학적으로 풀면 씬에 별도 타겟을 두지 않아도 되겠지만, 코드가 지저분해지므로 유니티 로컬 좌표계 시스템 사용
  • target_to_reach의 자식 오브젝트인 target_for_math는 hand_part와 tongs_part의 x축 로컬 오프셋을 유지한다.
  • robotic_arm의 계층 구조 중 첫 단계에서 크기가 100으로 설정되는 이상한 일이 벌어져서 유니티 좌표계와 차이가 있으므로, 축 기준만 로컬, 길이는 월드 좌표계 기준으로 해야 한다. tongs_part의 localposition.x에 parent.lossyScale.x를 곱하여 구한다. 조부모도 크기 변경을 해놨어서 그건 1.1 대충 곱해서 해결.
  • 설정한 오프셋이 실제 해당 타겟에 도착했을 때의 오프셋과 동일하도록 각도를 설정해야 한다. 따라서 target_to_reach의 rotation은 base에서 target_to_reach까지의 방향 벡터로 설정한다.
  • '대충' 계획대로는 됐는데 여전히 미묘하게 차이가 존재. magic number x,y,z를 더해서 해결해보려고 했으나 체스판 위치에 따라 달라짐. 어디에선가 생각한 것과 달리 계산되고 있는 곳이 있는게 분명.
    void Start()
    {
        // x_local_offset = arm_tongs.localPosition.x * arm_hand.lossyScale.x;
        x_local_offset = arm_tongs.localPosition.x * arm_hand.lossyScale.x * 1.1f;
    }

    void Update()
    {
        Vector3 direction = transform.position - arm_base.position;
        direction.y = 0; // Ignore the y-axis
        transform.rotation = Quaternion.LookRotation(direction);
        target_for_math.localPosition = new Vector3(-x_local_offset + magic_number_x, magic_number_y, magic_number_z);
    }

실패한 코드. 내일 월드 좌표계 좌표만으로 기하학적으로 다시 풀어보기.

profile
너 정말 **핵심**을 찔렀어

0개의 댓글