generated from Persson-dev/Godot-Xmake
stick pens on walls
This commit is contained in:
@@ -222,8 +222,8 @@ albedo_color = Color(0, 0.4, 1, 1)
|
|||||||
|
|
||||||
[sub_resource type="CylinderMesh" id="CylinderMesh_spot0"]
|
[sub_resource type="CylinderMesh" id="CylinderMesh_spot0"]
|
||||||
material = SubResource("StandardMaterial3D_8rx3k")
|
material = SubResource("StandardMaterial3D_8rx3k")
|
||||||
top_radius = 0.05
|
top_radius = 0.03
|
||||||
bottom_radius = 0.05
|
bottom_radius = 0.03
|
||||||
height = 0.2
|
height = 0.2
|
||||||
|
|
||||||
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_jv0gp"]
|
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_jv0gp"]
|
||||||
@@ -315,6 +315,8 @@ transitions = ["Start", "Movement", SubResource("AnimationNodeStateMachineTransi
|
|||||||
graph_offset = Vector2(18, 52)
|
graph_offset = Vector2(18, 52)
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody3D"]
|
[node name="Player" type="CharacterBody3D"]
|
||||||
|
collision_layer = 2
|
||||||
|
collision_mask = 3
|
||||||
|
|
||||||
[node name="Head" type="Node3D" parent="."]
|
[node name="Head" type="Node3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.55647, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.55647, 0)
|
||||||
|
|||||||
@@ -87,3 +87,5 @@ surface_material_override/0 = SubResource("StandardMaterial3D_pfpgv")
|
|||||||
shape = SubResource("ConcavePolygonShape3D_rit6o")
|
shape = SubResource("ConcavePolygonShape3D_rit6o")
|
||||||
|
|
||||||
[node name="Players" type="Node" parent="."]
|
[node name="Players" type="Node" parent="."]
|
||||||
|
|
||||||
|
[node name="Entities" type="Node" parent="."]
|
||||||
|
|||||||
@@ -3,13 +3,14 @@
|
|||||||
[ext_resource type="ArrayMesh" path="res://Assets/Models/Weapons/pen_base.res" id="1_clcko"]
|
[ext_resource type="ArrayMesh" path="res://Assets/Models/Weapons/pen_base.res" id="1_clcko"]
|
||||||
[ext_resource type="ArrayMesh" path="res://Assets/Models/Weapons/pen_lid.res" id="2_0u0nh"]
|
[ext_resource type="ArrayMesh" path="res://Assets/Models/Weapons/pen_lid.res" id="2_0u0nh"]
|
||||||
|
|
||||||
[node name="Stylo" type="Node3D"]
|
[node name="Stylo" type="Bullet"]
|
||||||
|
transform = Transform3D(3, 0, 0, 0, 3, 0, 0, 0, 3, 0, -7.45058e-09, 0)
|
||||||
|
|
||||||
[node name="Armature" type="Node3D" parent="."]
|
[node name="Armature" type="Node3D" parent="."]
|
||||||
transform = Transform3D(5, 0, 0, 0, 0.0178025, -4.99997, 0, 4.99997, 0.0178025, 0, 0, -0.0892955)
|
transform = Transform3D(5, 0, 0, 0, 0.0178025, -4.99997, 0, 4.99997, 0.0178025, 0, 0, -0.0828303)
|
||||||
|
|
||||||
[node name="pen_base" type="MeshInstance3D" parent="Armature"]
|
[node name="pen_base" type="MeshInstance3D" parent="Armature"]
|
||||||
transform = Transform3D(0.140708, 0, 0, 0, -1.67737e-08, 0.140708, 0, -0.140708, -1.67737e-08, -1.12406e-11, 0.00945318, -3.65384e-09)
|
transform = Transform3D(0.140708, 0, 0, 0, -1.6822e-08, 0.140708, 0, -0.140708, -1.6822e-08, -1.12406e-11, 0.00809256, -4.84818e-06)
|
||||||
mesh = ExtResource("1_clcko")
|
mesh = ExtResource("1_clcko")
|
||||||
skeleton = NodePath("")
|
skeleton = NodePath("")
|
||||||
|
|
||||||
|
|||||||
@@ -62,3 +62,10 @@ shoot={
|
|||||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[layer_names]
|
||||||
|
|
||||||
|
3d_physics/layer_1="World"
|
||||||
|
3d_physics/layer_2="No Team"
|
||||||
|
3d_physics/layer_3="Team 1"
|
||||||
|
3d_physics/layer_4="Team 2"
|
||||||
|
|||||||
24
include/client/Bullet.h
Normal file
24
include/client/Bullet.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <godot_cpp/classes/node3d.hpp>
|
||||||
|
#include <godot_cpp/classes/ray_cast3d.hpp>
|
||||||
|
|
||||||
|
namespace blitz {
|
||||||
|
|
||||||
|
class Bullet : public godot::Node3D {
|
||||||
|
GDCLASS(Bullet, godot::Node3D)
|
||||||
|
protected:
|
||||||
|
static void _bind_methods();
|
||||||
|
|
||||||
|
public:
|
||||||
|
Bullet();
|
||||||
|
~Bullet();
|
||||||
|
void _process(float delta);
|
||||||
|
void _ready() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_Stuck;
|
||||||
|
float m_LifeTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace blitz
|
||||||
56
src/client/Bullet.cpp
Normal file
56
src/client/Bullet.cpp
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
#include <client/Bullet.h>
|
||||||
|
|
||||||
|
#include <godot_cpp/classes/engine.hpp>
|
||||||
|
#include <godot_cpp/classes/physics_direct_space_state3d.hpp>
|
||||||
|
#include <godot_cpp/classes/physics_ray_query_parameters3d.hpp>
|
||||||
|
#include <godot_cpp/classes/world3d.hpp>
|
||||||
|
#include <godot_cpp/variant/utility_functions.hpp>
|
||||||
|
|
||||||
|
namespace blitz {
|
||||||
|
|
||||||
|
using namespace godot;
|
||||||
|
|
||||||
|
static constexpr float SPEED = 20.0f;
|
||||||
|
static constexpr float MaxAlive = 10.0f;
|
||||||
|
|
||||||
|
void Bullet::_bind_methods() {}
|
||||||
|
|
||||||
|
Bullet::Bullet() : m_Stuck(false) {}
|
||||||
|
|
||||||
|
void Bullet::_ready() {}
|
||||||
|
|
||||||
|
Bullet::~Bullet() {}
|
||||||
|
|
||||||
|
void Bullet::_process(float a_Delta) {
|
||||||
|
if (Engine::get_singleton()->is_editor_hint()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_LifeTime += a_Delta;
|
||||||
|
if (m_LifeTime > MaxAlive) {
|
||||||
|
queue_free();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_Stuck)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Vector3 start = get_position();
|
||||||
|
Vector3 finish = start + get_transform().basis.xform(Vector3{0, 0, -SPEED * a_Delta});
|
||||||
|
|
||||||
|
auto query = PhysicsRayQueryParameters3D::create(start, finish, 1);
|
||||||
|
auto result = get_world_3d()->get_direct_space_state()->intersect_ray(query);
|
||||||
|
|
||||||
|
if (result.is_empty()) {
|
||||||
|
set_position(finish);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Stuck = true;
|
||||||
|
Vector3 intersectPoint = result["position"];
|
||||||
|
|
||||||
|
auto* head = get_node<Node3D>("Armature");
|
||||||
|
head->set_global_position(intersectPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace blitz
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include <blitz/godot/NetworkInterface.h>
|
#include <blitz/godot/NetworkInterface.h>
|
||||||
|
#include <client/Bullet.h>
|
||||||
#include <client/ClientWorld.h>
|
#include <client/ClientWorld.h>
|
||||||
#include <client/FirstPersonPlayer.h>
|
#include <client/FirstPersonPlayer.h>
|
||||||
#include <client/Main.h>
|
#include <client/Main.h>
|
||||||
@@ -23,6 +24,7 @@ static void RegisterClasses() {
|
|||||||
GDREGISTER_ABSTRACT_CLASS(blitz::World);
|
GDREGISTER_ABSTRACT_CLASS(blitz::World);
|
||||||
GDREGISTER_CLASS(blitz::ClientWorld);
|
GDREGISTER_CLASS(blitz::ClientWorld);
|
||||||
GDREGISTER_CLASS(blitz::ServerWorld);
|
GDREGISTER_CLASS(blitz::ServerWorld);
|
||||||
|
GDREGISTER_CLASS(blitz::Bullet);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initialize_blitz_module(ModuleInitializationLevel p_level) {
|
static void initialize_blitz_module(ModuleInitializationLevel p_level) {
|
||||||
|
|||||||
Reference in New Issue
Block a user