Imagine placing this component in any scene representing a projectile in your video game, and it is ready for action. It provides common functionalities for standard projectiles.
- Requirements
- ✨Installation
- Getting started
- Exported parameters
- Accessible normal parameters
- Once upon the scene tree
- Functions
- Signals
- ✌️You are welcome to
- 🤝Contribution guidelines
- 📇Contact us
📢 We don't currently give support to Godot 3+ as we focus on future stable versions from version 4 onwards
- Godot 4+
You can download this plugin from the official Godot asset library using the AssetLib tab in your godot editor. Once installed, you're ready to get started
To manually install the plugin, create an "addons" folder at the root of your Godot project and then download the contents from the "addons" folder of this repository
This plugin has also been written in GDScript and you can find it on ProjectileComponent
This node functions like the others, serving as a child of another node. In this case, it is not restricted to only CharacterBody2D
, as bullets are typically Area2D
objects.
- Max speed
- Acceleration The max speed as the name say, defines the maximum reachable limit of speed that will be apply to the velocity.
The getter of the speed modify the value based on SpeedReductionOnPenetration
parameter.
The acceleration makes smoother to reach the maximum speed if you want to increase the juiciness of the movement. In case you don't want it just assign a zero value to it and the node will reach the maximum speed immediately
- Homing distance
- Homing strength
The homing distance defines the maximum distance the projectile will pursue the target if the target is defined. Leave it at zero if there is no distance limit.
The purpose of
HomingStrength
is to provide fine-grained control over how aggressively the projectile homes in on the target.
- Max penetrations
- Speed reduction on penetration
The max penetrations is an integer value that determines how many times the projectile can penetrate before emitting the
PenetrationComplete
signal. We do not queue-free the node as we leave the behavior to the user, allowing them to handle it by connecting to the signal. The speed reduction on penetration decreases the speed by this amount back to the original maximum speed each time a penetration occurs.
- Bounce enabled
- Bounce times The bounce enabled setting allows the projectile to bounce upon collision or another type of event. The bounce times parameter determines the number of times this projectile can bounce.
- projectile: Node2D
- direction: Vector2
- target: Node2D
- follow_target: bool
- penetration_count
- bounced_positions: Array[Vector2]
- Connects to the signal
FollowStarted
When this projectile starts to follow a target, the component checks if the target can be followed. This means:
- The target is not null.
- The homing distance to the target is less than the defined value.
If these conditions are met, the homing behavior begins. Depending on the
HomingStrength
, the projectile starts to follow the target smoothly.
The projectile starts moving in the Direction
and at the MaxSpeed
defined as parameters. In this state, the projectile uses LookAt
to orient itself towards the provided direction.
The target is swapped to the provided one as parameter and emit the signal TargetSwapped
The projectile stop following the target if this is defined. This function set the Target
to null and FollowTarget
to false
The projectile begins to follow the target, and this behavior is activated. This function set the target to NewTarget
and FollowTarget
to true
If a Target
is defined, this function returns the normalized direction from this projectile to the target. It returns Vector2.ZERO
when the Target
is null.
Update the direction to follow the target if the projectile is on following mode.
The projectile bounces in the direction defined by the NewDirection
parameter if bouncing is enabled and there are remaining bounces for this projectile. Every succesfull bounce append the position to the BouncedPositions
array
Typically, you pass the WallNormal
as a parameter to bounce in the opposite direction, but we don't want to restrict things; the NewDirection
is flexible. This action also emits the Bounced
signal.
- FollowStarted(Node2D target)
- FollowStopped(Node2D target)
- TargetSwapped(Node2D CurrentTarget, Node2D PreviousTarget)
- HomingDistanceReached()
- Bounced(Vector2 position)
- Penetrated(int RemainingPenetrations)
- PenetrationComplete()
GodotParadise is available for free.
If you're grateful for what we're doing, please consider a donation. Developing GodotParadise requires massive amount of time and knowledge, especially when it comes to Godot. Even $1 is highly appreciated and shows that you care. Thank you!
Thank you for your interest in Godot Paradise!
To ensure a smooth and collaborative contribution process, please review our contribution guidelines before getting started. These guidelines outline the standards and expectations we uphold in this project.
📓Code of Conduct: We strictly adhere to the Godot code of conduct in this project. As a contributor, it is important to respect and follow this code to maintain a positive and inclusive community.
If you have built a project, demo, script or example with this plugin let us know and we can publish it here in the repository to help us to improve and to know that what we do is useful.