Note temp in checkobstaclecollision is  a local variable that is why i am not declaring upfront