bullet physics seem better, need to figure out collisions and collision points

This commit is contained in:
derek
2024-10-23 11:32:18 -05:00
parent 9e644fe79f
commit d5300779a0
4 changed files with 35 additions and 29 deletions

View File

@@ -77,11 +77,15 @@ height = 1.53305
radius = 0.055
[node name="Bullet" type="RigidBody3D"]
collision_layer = 0
top_level = true
collision_layer = 32
collision_mask = 109
mass = 0.1
center_of_mass_mode = 1
continuous_cd = true
contact_monitor = true
max_contacts_reported = 1
max_contacts_reported = 10
angular_damp = 100.0
script = ExtResource("1_oj0f5")
[node name="Cylinder" type="MeshInstance3D" parent="."]
@@ -119,7 +123,4 @@ stream = ExtResource("3_6j0l2")
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0)
shape = SubResource("CylinderShape3D_tqvit")
[node name="RayCast3D" type="RayCast3D" parent="."]
target_position = Vector3(0, 0, -1)
[connection signal="body_entered" from="." to="." method="_on_body_entered"]

View File

@@ -1,10 +1,11 @@
[gd_scene load_steps=14 format=3 uid="uid://dq3pqbjg7o241"]
[gd_scene load_steps=15 format=3 uid="uid://dq3pqbjg7o241"]
[ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_iqxey"]
[ext_resource type="PackedScene" uid="uid://brl0bsqjl5dg3" path="res://assets/mac_10.tscn" id="2_bbv4q"]
[ext_resource type="Material" uid="uid://br2pyyyl2n3cx" path="res://assets/materials/prototype/prototype1.tres" id="3_ol40x"]
[ext_resource type="PackedScene" uid="uid://b5eclfg0cmmal" path="res://assets/revolver_1.tscn" id="3_tt31v"]
[ext_resource type="PackedScene" uid="uid://drwae3loscbw7" path="res://assets/player.tscn" id="4_1k4dj"]
[ext_resource type="PackedScene" uid="uid://cnfc8rtk6l1d8" path="res://assets/crate1.tscn" id="6_4jfab"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_s7a4u"]
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
@@ -25,6 +26,21 @@ glow_enabled = true
[sub_resource type="BoxShape3D" id="BoxShape3D_1u1id"]
[sub_resource type="Animation" id="Animation_qlawa"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(6.78104, 1.26555, -18.3016)]
}
[sub_resource type="Animation" id="Animation_l1fwm"]
resource_name = "new_animation"
length = 7.0
@@ -42,21 +58,6 @@ tracks/0/keys = {
"values": [Vector3(6.78104, 1.26555, -18.3016), Vector3(6.78104, 8.4087, -18.3016), Vector3(-4.99932, 8.4087, -18.3016), Vector3(21.2047, 8.4087, -18.3016), Vector3(21.2047, 8.4087, -18.3016), Vector3(21.2047, 8.4087, 16.4439)]
}
[sub_resource type="Animation" id="Animation_qlawa"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(6.78104, 1.26555, -18.3016)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_dlky4"]
_data = {
"RESET": SubResource("Animation_qlawa"),
@@ -104,3 +105,6 @@ libraries = {
"": SubResource("AnimationLibrary_dlky4")
}
autoplay = "new_animation"
[node name="Crate1" parent="." instance=ExtResource("6_4jfab")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 17.8157, 3.08948, -17.9593)

View File

@@ -21,7 +21,7 @@ var player_velocity
func _ready():
visible = false
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed)
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed) + player_velocity
# Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -33,10 +33,11 @@ func _physics_process(delta):
visible = true
func _on_body_entered(body: Node) -> void:
if body.is_in_group("testtest"):
if !body.is_in_group("player"):
mesh.visible = false
#bullethole effect
@@ -47,9 +48,9 @@ func _on_body_entered(body: Node) -> void:
#else:
#instance_bullethole.look_at(body.get_collision_point() + body.get_collision_normal())
#move rigidbodies
if body.is_in_group("scene_rigidbody"):
body.linear_velocity += transform.basis * Vector3(0,0,-1 * bullet_force_mod)
##move rigidbodies
#if body.is_in_group("scene_rigidbody"):
#body.linear_velocity += transform.basis * Vector3(0,0,-1 * bullet_force_mod)
if body.is_in_group("breakable"):
var current_velocity = transform.basis * Vector3(0,0,-1 * bullet_force_mod)

View File

@@ -200,14 +200,14 @@ func _physics_process(delta):
#initiate fast movement -- may be done with this block
#change sounds with speed
if moving_fast:
var wind_volume = clamp( velocity.length() - 20 ,-20,10)
var wind_volume = clamp( velocity.length() - 20 ,-80,10)
ear_wind.volume_db = wind_volume
#reset at apex
#cache fastest speed
if abs(velocity.y) > moving_fast_top_speed:
moving_fast_top_speed = abs(velocity.y)
#print("TOP SPEED = " + str(moving_fast_top_speed))
#Land Sound
if velocity.y < .1 and self.is_on_floor() and moving_fast == true:
print("LAND SOUND")