Detecting the Direction of a Collision

前端 未结 5 919
执笔经年
执笔经年 2021-02-07 13:52

A square tile collides with another square tile. The bartender says...

I have:

  • The height, width, x, and y of both tiles.
  • The 2D vector of the mo
5条回答
  •  耶瑟儿~
    2021-02-07 14:32

    you have to model your square to capture the orientation too , just with (x,y,height) of the square , orientation i mean whether its in first ,second ,third of fourth quadrant , may be by modeling all four corner vertices of square .

    then you need to determine , all the four vectors that make this square

    find cosine between the 2D Vector you have with each side of square for example if cosine of given side and 2D Vector is 1 , then both are orthogonal or 0 they are perpendicular , any other value would fall in between

    or any other vector algebra tricks on how you want to determine/define your collision !

提交回复
热议问题