0 votes

Hello

I am a beginner at Godot and programming overall, but, for various reasons I've decided to create a game on my own. That said I will appreciate any tips without hassling anyone for specifics, I can research things on my own. But I have no idea how to even begin to tackle this specific problem.

I want to create a top down shooter cRPG where stats matter amongst others for hit chance. Now, I want to make hits take place where I aim while taking into account various things, such as distance, obstacles, enemy stats, weapon stats, etc. Alas, I have no idea how to exactly make these "hits" to appear in a reticle, with whole mechanic being also used by enemies.

My only idea right now, is that it would work like a normal shooter - bullets fly normally, but the ones that are "successful" ignore everything and hit a spot in the aiming reticle (to put it into perspective, shooting beneath someone's legs behind them, so even though the bullet flew at that someone, the shot was aimed behind, so it did not hit them). Whether or not the success would occur, would be taken from stats - I believe once I learn how to make this way of shooting, I should be able to figure the rest out on my own. But right now, I have no idea how to begin.

Thank you for any and all tips.

Godot version 3.2.2 Stable
in Engine by (12 points)

1 Answer

+1 vote

Ray-casting is the most efficient way (afaik) of handling shoot/hit events. Now if you want to add physics (gravity to the bullet, collision detection, etc...) you can use Rigidbodies where your reticle can be an Area. I believe you are in 3D here but the principles are the same in 2D

Sometimes, I use a Raycast and add animations to fake the physics. Just a lot simpler

by (91 points)

Thank you for the answer.

Considering I would simply use Ray-cast, what would be the best approach to make it get data on a specific path to the cursor/aiming reticle? Should I combine both ray-cast and spread to form a fan so to speak and have any missing shots hit randomly wherever the raycast ends?

Since currently I am unsure how to make shots end at the reticle as long as the ray-cast can go there (assuming for example it ends at obstacles like walls, trees, etc.). I've found a tutorial on having hits on the end of the raycast, but in that case it looks for a hitbox. And I'd like it to end at the cursor.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.