This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hi, Im just wondering if there is a simple way for you to display the ammo you have. For my game, you collect it along the way and I want to be able to let the player see how much they have. Any advice and code is welcome thank you

in Engine by (39 points)

Depending upon your setup, you may only need to put a Label on the screen which updates with the player's bullet count. When bullets are collected, update this number (usually through a signal to a function).

how would I code it ??

1 Answer

0 votes

Add an area2d to your bullet

create a label and give it a script

Connect the area entered signal to label

In the label script, create a variable

var bullets_num

func onareabodyentered(body):
if area isingroup("player"):
bullets_num += 1

under the process function

text = bullets_num

by (831 points)
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.