百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

godot-native-bullets-plugin

> 编程语言
开源

高效地生成和移动大量物体,如子弹(用于子弹地狱),粒子等。

197 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

高效地生成和移动大量物体,如子弹(用于子弹地狱),粒子等。

Godot Native Bullets

Efficiently spawn and move high amounts of objects like bullets for bullet hells, particles and more.

This is a GDNative plugin, compatible with Godot 3.4.x and up.

Not compatible with Godot 4.x.

The versions of the pre-built binaries are as follows:

  • Windows x86-64 (v1.2.1)
  • Linux x86-64 (v1.2.1)
  • macOS Universal (x86-64 + arm64, v1.2.1)

Notice: to make sure you have the latest binary version you can build from source.

See Compiling and extending the plugin.

Features

  1. Spawn and move high amounts of bullets.
  2. Configure multiple types of bullets, each with its own behaviour.
  3. Set custom properties to categories of bullets or to any single bullet.
  4. Customize bullets using shaders.
  5. Configure bullets with a collision shape, layer and mask of your choice.
  6. Toggle collision detection on or off for each type of bullet.
  7. Set the pool size and z index for every bullet type.
  8. Choose the target viewport or canvas layer.
  9. Extend the plugin using C++.

Step by step

Installation

  1. Copy the addons/native_bullets folder in your addons folder.
  2. Navigate to Project -> Project Settings -> Plugin and enable the Native Bullets plugin.

For best performance, toggle use_bvh off in Project Settings -> Physics -> 2d.

BulletKit creation

The first thing to do is create a BulletKit resource and choose how bullets will appear and behave tweaking its properties.

  1. Create a new empty resource and assign one of the scripts you can find in the addons/native_bullets/kits folder to it. In this example, we'll assign the basic_bullet_kit.gdns script. New properties will appear in the resource inspector.

  2. To get started, fill the texture property with any texture you have.

  3. As the material, you can use a new material resource using the animated_shader.gdshader you can find in the utils folder. This shader takes care of animating your bullets if you specify more than 1 frame in its parameters.

  4. For now, turn off collisions_enabled, turn use_viewport_as_active_rect on, turn rotate off and set unique_modulate_component to None. See the Reference section to learn more.

This BulletKit resource is now ready to be used!

BulletsEnvironment node

In order to spawn bullets in the scene, a BulletsEnvironment node is needed. This is the node that will define which kinds of bullets will be available during its lifetime. Only one BulletsEnvironment node can be active at the same time and if you add another one to the scene tree its configuration will replace the previous one.

The BulletsEnvironment node has to be configured to choose which kinds of bullets will be able to spawn, their maximum amount and their z indices.

  1. Create a new BulletsEnvironment node.

  2. Choose how many types of bullets this node will be able to spawn. Increase bullet_types_amount to 1 for now.

  3. A new section of the inspector will appear below. Unfold the Bullet Type 0 entry. Here, drag & drop the BulletKit resource you created earlier to let the node know that you'll want to spawn the bullet described in it!

  4. Choose the maximum amount of bullets setting the pool_size property and the their z_index. 3000 and 1 will be ok. Leave the parent_hint property empty, it will make the bullets spawn in the nearest Viewport or CanvasLayer up in the scene tree.

Nice! Now the bullets are ready.

Spawn bullets

The last step is to spawn a lot of those bullets.

You can use the utilities provided by the plugin to spawn bullets in a variety of ways, but let's do it manually for now.

Create a script.

…

Here you go! Now attach this script to one of your 2D nodes, start the game, press space to shoot and right/left to change the bullets direction!

More examples

The repository contains an examples folder containing a few pre-configured scenes, ready to be played in the editor.

Below are reported some of the most common things you can do.

Bullets spawning

Spawn bullets.

…

Bullets handling

You can manipulate and set properties of bullets even after you spawned them.

gdscript
export(float) var bullets_speed = 50.0

func shoot():
	var bullet_kit = preload("res://path/to/basic_bullet_kit.tres")

	# Use `obtain_bullet` to receive an opaque BulletID object.
	var bullet_id = Bullets.obtain_bullet(bullet_kit)

	# You can then use `bullet_id' to set and get properties.
	Bullets.set_bullet_property(bullet_id, "transform", Transform2D(global_rotation, global_position))
	Bullets.set_bullet_property(bullet_id, "velocity", Vector2(cos(global_rotation), sin(global_rotation)) * bullets_speed)

Collision detection

When a bullet collides with a body or an area, the best way to get the data of the colliding bullet is to connect to the area_shape_entered signal.

…

Reference

The plugin has a few main components, explained below:

@ BulletKit

This is the resource used to configure each type of bullet.

Every BulletKit spawns its own bullet instances that support different kinds of properties.

The plugin comes with 4 base variants that can be customized via the editor:

BasicBulletKit

This is the most basic BulletKit, makes bullets move, generally at constant speed.

It's configurable with:

  • texture: controls what texture is sent to the bullet material.
  • material: the material used to render each bullet.
  • collisions_enabled: enables or disables collision detection, turning it off increases performance.
  • collision_layer: the collision layer to use during collision detection. Visible only if collisions_enabled is on.
  • collision_mask: the collision mask to use during collision detection. Visible only if collisions_enabled is on.
  • collision_shape: the CollisionShape to use during collision detection. Visible only if collisions_enabled is on.
  • use_viewport_as_active_rect: if enabled, uses the current viewport to detect whether a bullet should be deleted.
  • active_rect: the rect outside of which the bullets get deleted. Visible only if use_viewport_as_active_rect if off.
  • rotate: controls whether the bullets automatically rotate based on their direction of travel.
  • unique_modulate_component: controls which modulate component in the material will be used as a unique value for each bullet instance. This can be used to offset bullets animation frames by unique amounts inside shaders and it's needed due to Godot not supporting material instance properties in 3.x.
  • data: custom data you can assign to the BulletKit.

Bullets spawned by a BasicBulletKit have those properties:

  • item_rid: the bullet canvas item RID, used internally. Read-only.
  • cycle: the number of times the bullet was recycled, used internally. Read-only.
  • shape_index: the index of the collision shape used by this bullet, used internally. Read-only.
  • transform: the Transform2D used to position and rotate the bullet.
  • velocity: the Vector2 that will be used to update the bullet position.
  • lifetime: how much time the bullet has been alive.
  • data: custom data you can assign to any bullet.

FollowingBulletKit

This BulletKit lets you define a target node for each bullet and a turning speed used to chase it around.

It's configurable with:

  • texture: controls what texture is sent to the bullet material.
  • bullets_turning_speed: the turning speed with which the bullets will rotate towards the target node.
  • material: the material used to render each bullet.
  • collisions_enabled: enables or disables collision detection, turning it off increases performance.
  • collision_layer: the collision layer to use during collision detection. Visible only if collisions_enabled is on.
  • collision_mask: the collision mask to use during collision detection. Visible only if collisions_enabled is on.
  • collision_shape: the CollisionShape to use during collision detection. Visible only if collisions_enabled is on.
  • use_viewport_as_active_rect: if enabled, uses the current viewport to detect whether a bullet should be deleted.
  • active_rect: the rect outside of which the bullets get deleted. Visible only if use_viewport_as_active_rect if off.
  • rotate: controls whether the bullets automatically rotate based on their direction of travel.
  • unique_modulate_component: controls which modulate component in the material will be used as a unique value for each bullet instance. This can be used to offset bullets animation frames by unique amounts inside shaders and it's needed due to Godot not supporting material instance properties in 3.x.
  • data: custom data you can assign to the BulletKit.

Bullets spawned by a FollowingBulletKit have those properties:

  • target_node: the Node2D the bullet will chase.
  • item_rid: the bullet canvas item RID, used internally. Read-only.
  • cycle: the number of times the bullet was recycled, used internally. Read-only.
  • shape_index: the index of the collision shape used by this bullet, used internally. Read-only.
  • transform: the Transform2D used to position and rotate the bullet.
  • velocity: the Vector2 that will be used to update the bullet position.
  • lifetime: how much time the bullet has been alive.
  • data: custom data you can assign to any bullet.

DynamicBulletKit

Lets you define bullets that change their behaviour based on their lifetime.

It's configurable with:

  • texture: controls what texture is sent to the bullet material.
  • lifetime_curves_span: the reference lifespan used by the curves to determine their current value.
  • lifetime_curves_loop: controls whether the curves will loop around when lifetime goes past lifetime_curves_span.
  • speed_multiplier_over_lifetime: controls the bullet speed multiplying its velocity magnitude by the value defined in this curve, based on the bullet lifetime.
  • rotation_offset_over_lifetime: controls the bullet rotation offsetting its initial rotation by the value in radians defined in this curve, based on the bullet lifetime.
  • material: the material used to render each bullet.
  • collisions_enabled: enables or disables collision detection, turning it off increases performance.
  • collision_layer: the collision layer to use during collision detection. Visible only if collisions_enabled is on.
  • collision_mask: the collision mask to use during collision detection. Visible only if collisions_enabled is on.
  • collision_shape: the CollisionShape to use during collision detection. Visible only if collisions_enabled is on.
  • use_viewport_as_active_rect: if enabled, uses the current viewport to detect whether a bullet should be deleted.
  • active_rect: the rect outside of which the bullets get deleted. Visible only if use_viewport_as_active_rect if off.
  • rotate: controls whether the bullets automatically rotate based on their direction of travel.
  • unique_modulate_component: controls which modulate component in the material will be used as a unique value for each bullet instance. This can be used to offset bullets animation frames by unique amounts inside shaders and it's needed due to Godot not supporting material instance properties in 3.x.
  • data: custom data you can assign to the BulletKit.

Bullets spawned by a DynamicBulletKit have those properties:

  • transform: the Transform2D used to position and rotate the bullet.
  • starting_transform: the baseline Transform2D, curves will apply their changes based on this transform. This is automatically set when you manually edit transform.
  • velocity: the Vector2 that will be used to update the bullet position.
  • starting_speed: the baseline speed, curves will apply their changes based on this speed value. This is automatically set when you manually edit velocity.
  • item_rid: the bullet canvas item RID, used internally. Read-only.
  • cycle: the number of times the bullet was re

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C++

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言