- Home /
How to SweepTest diagonally (Top Right/ Top Left)?
Hi, below are some of of my codes. I want to do a sweeptest for top right/ top left direction at approximately 45 degree. If there are no tiles at the top right/ top left direction, the gameObject will jump on top of the tile beside it. However, currently, my gameObject will not jump on top of the tile beside it even when there are no tiles at the top right/ top left direction. Would really appreciate it if anyone can kindly help me with the problem, thanks!
Direction.Set( 1, 0, 0 );
DiagonalDirection = Quaternion.AngleAxis( 45, Vector3.forward ) * Vector3.right;
// Check left/ right (the direction that the TB is facing)
if( rigidbody.SweepTest( Direction, out hit, 5 ) )
{
if ( hit.collider.gameObject.tag == "EndPoint" )
{
DestroyTB();
//return;
}
else
{
// Check topright
if( rigidbody.SweepTest( DiagonalDirection, out hit, 15 ) )
{
//print ("GOT WALL");
TB_State = TetrisBabyState.Turning;
}
else
{
//print ("NO WALL");
TB_State = TetrisBabyState.Jumping;
}
}
}
Comment
Your answer