Hello guys!
Just a noob question here.
So here's the setup.
I want to implement a bullet hit using raycast function.
For example I have a resolution of 480x980.
Let's say my hero is at (240, 900) and the enemy is at (400, 200)
I want to hit the enemy instantly using bullet from my players coordinate. I want to use raycast if possible.
Please help me for the logic, and event listeners .
Thank you ☺️☺️
Comments
if so have you checked this wiki page? https://wiki.gideros.rocks/index.php/B2.World:rayCast
I used it once but I think that was with reactphysics3d plugin. That should work the same for 2d.
I have read math.raycast api but I don't know how to implement. I don't want to use box2d if possible because it is a very tiny game. 😅
Likes: MoKaLux
In the example, four things happen:
- the nearest shape to the mouse is returned.
- The shape is colored in green or yellow depending on wether the mouse is inside or outside.
- The nearest point on that shape (from the mouse) is computed (in purple)
- A ray cast from the center of the scene and in the direction of the mouse is performed. The resulting collision (if any) is shown with a blue dot.
Likes: MoKaLux, SinisterSoft
Likes: MoKaLux
Likes: MoKaLux