Your First 2D game: Creating the Enemy - randomize mod suggestion?
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Stale
- Domain
- documentation, game-dev
Research direction
Start with the tutorial page at getting_started/first_2d_game/04.creating_the_enemy.html and review the current enemy animation snippet. Update the example to use the proposed Array and pick_random() approach, including the suggested explanation of the relevant Array method. Done when the tutorial accurately presents the revised example and remains clear for learners.
Written by the indexing model from the issue text.
Description
Your Godot version:
4.2.2
Issue description:
Currently, the tutorial shares this snippet:
func _ready():
var mob_types = $AnimatedSprite2D.sprite_frames.get_animation_names()
$AnimatedSprite2D.play(mob_types[randi() % mob_types.size()])
Thoughts on this?
func _ready():
var mob_types = $AnimatedSprite2D.sprite_frames.get_animation_names()
$AnimatedSprite2D.play(Array(mob_types).pick_random())
The pick_random() method is relatively straightforward to understand, and discussing the Array data type and its methods can be quite valuable for learning purposes.
Via https://docs.godotengine.org/en/4.0/classes/class_array.html#class-array-method-pick-random
URL to the documentation page (if already existing):
https://docs.godotengine.org/en/stable/getting_started/first_2d_game/04.creating_the_enemy.html
- Dominant language
- reStructuredText
- Stars
- 5.7k
- Forks
- 3.8k
- Avg merge
- 7d 14h
- Merged PRs (30d)
- 41
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from godotengine/godot-docs
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
godotengine/godot-docs#12394 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
godotengine/godot-docs#12366 · 1 comment ·
-
area:class reference area:manual enhancement topic:2d topic:physics
Difficulty 1/5 1-3 hours Newbie friendliness 87/100
godotengine/godot-docs#12364 · 3 comments ·
-
bug content:website
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
godotengine/godot-docs#12360 · 1 comment ·
-
bug content:website
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
godotengine/godot-docs#12348 ·
All issues in godotengine/godot-docs
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Ecosystem: ClawMetry — the Qwen Code reader is now free and open source (follow-up to #9294 / #9338) Opencategory/integration priority/P3 scope/documentation status/ready-for-human type/feature-request
Difficulty 1/5 Under an hour Newbie friendliness 84/100