Hello. After going through the 2d platformer part of the course, I wanted to know if I could get my character to instantiate a projectile just like here. I know that I would have to make it move on the x axis instead of the y, but I don’t know how to make it so that the projectile instantiates in the direction that the player is facing.
void Shoot()
{
RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.right);
if (hit.transform != null)
{
Debug.Log("You Hit: " + hit.transform.name);
}
}
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.