// -- Handle input and movement --
float inputX = Input.GetAxis("Horizontal");
if (inputX > 0)
{
transform.eulerAngles = new Vector3(0, 0, 0);
}
else if (inputX < 0)
{
transform.eulerAngles = new Vector3(0, 180, 0);
}
// Move
if (!m_rolling )
m_body2d.velocity = new Vector2(inputX * m_speed, m_body2d.velocity.y);
//Set AirSpeed in animator
m_animator.SetFloat("AirSpeedY", m_body2d.velocity.y);
// -- Handle Animations --
//Wall Slide
m_isWallSliding = (m_wallSensorR1.State() && m_wallSensorR2.State()) || (m_wallSensorL1.State() && m_wallSensorL2.State());
m_animator.SetBool("WallSlide", m_isWallSliding);
//Attack
if(Input.GetMouseButtonDown(0) && m_timeSinceAttack > 0.25f && !m_rolling &&
!m_animator.GetCurrentAnimatorStateInfo(0).IsName("Attack") )
{
PlaySound("ATTACK");
m_currentAttack++;
// Loop back to one after third attack
if (m_currentAttack > 3)
m_currentAttack = 1;
// Reset Attack combo if time since last attack is too large
if (m_timeSinceAttack > 1.0f)
m_currentAttack = 1;
// Call one of three attack animations "Attack1", "Attack2", "Attack3"
m_animator.SetTrigger("Attack" + m_currentAttack);
Collider2D[] collider2Ds = Physics2D.OverlapBoxAll ( pos.position , boxSize ,0);
foreach (Collider2D collider in collider2Ds)
{
if(collider.tag == "Enemy")
{ collider.GetComponent<Enemy>() .TakeDamage(2); }
}
// Reset timer
m_timeSinceAttack = 0.0f;
}
// Swap direction of sprite depending on walk direction
if (inputX > 0)
{
GetComponent<SpriteRenderer>().flipX = false;
m_facingDirection = 1;
}
else if (inputX < 0)
{
GetComponent<SpriteRenderer>().flipX = true;
m_facingDirection = -1;
}
케릭터가 좌우로 움직일때 히트박스는 y축 반전으로 바뀌면서 따라다니는데 케릭터가 오른쪽만 보고있는데 어케 수정해야하나요
6차 원칙과 국어 배우기요
스케일 반전
위에서 트랜스폼을 반전하고, 밑에서 스프라이트를 뒤집으니 겹치는게 아닌 가싶네요! 아니면, 애니메이터에서 플립을 수정하고 있어서 스크립트에서 반영이 안되는 것일수도 있고요
히트박스랑 케릭터랑 따로 플립을 해줘야하는줄 알았어요. 해결했습니다. 감사합니다!!