Rally Rush
Loading...
Searching...
No Matches
beam.hpp
Go to the documentation of this file.
1#ifndef BEAM_HPP
2#define BEAM_HPP
3
4#include <godot_cpp/classes/area3d.hpp>
5#include <godot_cpp/classes/capsule_mesh.hpp>
6#include <godot_cpp/classes/capsule_shape3d.hpp>
7#include <godot_cpp/classes/collision_shape3d.hpp>
8#include <godot_cpp/classes/mesh.hpp>
9#include <godot_cpp/classes/mesh_instance3d.hpp>
10#include <godot_cpp/classes/shape3d.hpp>
11
12namespace godot {
14class Beam : public Area3D {
15 GDCLASS(Beam, Area3D);
17 static void _bind_methods();
18public:
20 virtual void _enter_tree() override;
22 virtual void _process(double delta_time) override;
24 void body_entered(Node3D *node);
26 void set_from_to(Vector3 from, Vector3 to);
28 void set_end_time(float time_from_now);
29private:
30 MeshInstance3D *mesh_instance{nullptr};
31 Ref<CapsuleMesh> mesh{};
32 CollisionShape3D *collision_shape{nullptr};
33 Ref<CapsuleShape3D> shape{};
34 float end_time{0.f};
35};
36}
37
38#endif // !BEAM_HPP
Area3D with a MeshInstance3D that resizes itself based on a from and to position and damages any obje...
Definition beam.hpp:14
void set_from_to(Vector3 from, Vector3 to)
Transform self and shapes to stretch from -> to.
Definition beam.cpp:34
float end_time
Definition beam.hpp:34
static void _bind_methods()
Required to be a valid godot class.
Definition beam.cpp:6
Ref< CapsuleShape3D > shape
Definition beam.hpp:33
void set_end_time(float time_from_now)
Pass in a duration and set the destroy timer for this object.
Definition beam.cpp:47
virtual void _enter_tree() override
Get child collision shape and mesh instance. Assumes both have a Capsule primitive shape....
Definition beam.cpp:10
virtual void _process(double delta_time) override
Destroy self after end time passes.
Definition beam.cpp:24
CollisionShape3D * collision_shape
Definition beam.hpp:32
Ref< CapsuleMesh > mesh
Definition beam.hpp:31
void body_entered(Node3D *node)
Deal damage on whatever enters this node. Configure what to damage using collision mask.
Definition beam.cpp:30
MeshInstance3D * mesh_instance
Definition beam.hpp:30
GDCLASS(Beam, Area3D)
Definition beacon_powerup.cpp:6