It's always trigonometry where I get stuck and it's hard to avoid it in 3D!!!
I have a 2-D game in a 3-D world. Very simple the player Mesh can move in X and Z coords only. Around my SQUARE arena I have a boundary wall. I would like my Mesh to 'bounce' off this wall realistically - i.e. If it hits perpendiclar (at 90degrees), it will recoil stright backwards.
I know the angle of reflection = angle of incidence, but how can I code this?
I looked at Cosines, because the Cosine of 90degrees is 0, but it doesn't fit for other angles..
(I haven't touched trig for years and it shows :((( )
Plus I need to convert EntityYaw(Mesh) to whatever to decipher exactly which wall it is hitting, whether(for want of better descriptions) North, South, East or West...
If it's of any consequence, my walls are built from single-unit primitive cubes (made using CopyEntity from a Master)
I have a 2-D game in a 3-D world. Very simple the player Mesh can move in X and Z coords only. Around my SQUARE arena I have a boundary wall. I would like my Mesh to 'bounce' off this wall realistically - i.e. If it hits perpendiclar (at 90degrees), it will recoil stright backwards.
I know the angle of reflection = angle of incidence, but how can I code this?
I looked at Cosines, because the Cosine of 90degrees is 0, but it doesn't fit for other angles..
(I haven't touched trig for years and it shows :((( )
Plus I need to convert EntityYaw(Mesh) to whatever to decipher exactly which wall it is hitting, whether(for want of better descriptions) North, South, East or West...
If it's of any consequence, my walls are built from single-unit primitive cubes (made using CopyEntity from a Master)