+1 vote

Hello, Striker again, i'm making progress in my game and more doubts began to appear on how do i make some things, from there i do some research just so i don't ask something that has already been asked before, but with no clear answer to my question i need to ask: how do i stop my bullet? weird because on a top down game you wouldn't need to stop your bullets, but to the logic of my game the player should be able to point and shoot, and the bullet should stop where the player shot (like if it feel on the floor, just like physics would work), i attempted to write some script but no success yet, so "how do i stop my bullet?" (just to remember this is for a top down game!)

in Engine by (81 points)

1 Answer

0 votes
Best answer

I think you are making it kind of complicated. I think that using a RayCast from the gun to check if something was hit, and a particle for the bullet body would work very well.

However if you want realistic bullet behaviour, I see two possibilities. Both use PhysicsBody and work in either 2d or 3d :
Note : I use the names of the 3d nodes, the 2d nodes have the same names with '2d' attached to the end

  1. Use a RigidBody for the bullet. That's it really, when the gun shoots create a bullet instance in front of the gun, give it velocity with applycentralimpulse and it will collide and react correctly. It however also is affected by gravity, so this might be a tad too realistic
  2. Use a KinematicBody. The KinematicBody node allows you to move a physics object however you want in the physics_process method. With the test_move method, you can check whether the body is colliding with something. When that is the case, react accordingly (delete the bullet, apply gravity to it etc..)

Those two solutions could answer your question. I however would advise against them, and direct you towards the RayCast solution : this is a case where too much physics could ruin the gameplay, except if it is a core/fun gameplay element.

Hope it helped,
TheFamousRat

by (305 points)
selected by

i like the idea of raycasting, and i probably could find a way to get the mouse position and translate that to be the limit to where the bullet goes. Thanks for the help.

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 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 webmaster@godotengine.org with your username.

Categories