stuff #1

Closed
Aiksi wants to merge 2 commits from advanced_bouncing into main
9 changed files with 278 additions and 5 deletions
Showing only changes of commit b19ae6be25 - Show all commits

71
Ball/bal213C.tmp Normal file
View File

@ -0,0 +1,71 @@
[gd_scene load_steps=11 format=3 uid="uid://dd1e3u5cyy3mk"]
[ext_resource type="Material" uid="uid://ccktnp41cys0r" path="res://Ball/Meshes/ball_material.tres" id="1_5n3i6"]
[ext_resource type="Script" path="res://Ball/ball_test.gd" id="1_s3xmr"]
[sub_resource type="SphereShape3D" id="SphereShape3D_jblqj"]
radius = 0.1
[sub_resource type="SphereMesh" id="SphereMesh_52mtx"]
[sub_resource type="SphereShape3D" id="SphereShape3D_862wy"]
[sub_resource type="SphereShape3D" id="SphereShape3D_dwt7q"]
[sub_resource type="BoxMesh" id="BoxMesh_1auv0"]
[sub_resource type="SphereMesh" id="SphereMesh_xquva"]
radius = 0.2
height = 0.4
[sub_resource type="SphereMesh" id="SphereMesh_bnhf3"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_5h0ki"]
transparency = 1
albedo_color = Color(1, 0.372549, 1, 0.701961)
[node name="BallBase" type="RigidBody3D"]
collision_layer = 0
collision_mask = 0
gravity_scale = 0.0
continuous_cd = true
lock_rotation = true
linear_damp_mode = 1
angular_damp_mode = 1
script = ExtResource("1_s3xmr")
speed = 20.0
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_jblqj")
[node name="BallMesh" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.0029127)
mesh = SubResource("SphereMesh_52mtx")
surface_material_override/0 = ExtResource("1_5n3i6")
[node name="BallBody" type="StaticBody3D" parent="."]
collision_layer = 4
collision_mask = 5
[node name="CollisionShape3D" type="CollisionShape3D" parent="BallBody"]
shape = SubResource("SphereShape3D_862wy")
[node name="AnchorBody3D" type="StaticBody3D" parent="."]
top_level = true
collision_layer = 4
collision_mask = 5
[node name="CollisionShape3D" type="CollisionShape3D" parent="AnchorBody3D"]
shape = SubResource("SphereShape3D_dwt7q")
[node name="MeshInstance3D" type="MeshInstance3D" parent="AnchorBody3D"]
mesh = SubResource("BoxMesh_1auv0")
[node name="TestMesh" type="MeshInstance3D" parent="."]
visible = false
mesh = SubResource("SphereMesh_xquva")
[node name="TestMesh2" type="MeshInstance3D" parent="."]
visible = false
mesh = SubResource("SphereMesh_bnhf3")
surface_material_override/0 = SubResource("StandardMaterial3D_5h0ki")

71
Ball/balE32A.tmp Normal file
View File

@ -0,0 +1,71 @@
[gd_scene load_steps=11 format=3 uid="uid://dd1e3u5cyy3mk"]
[ext_resource type="Material" uid="uid://ccktnp41cys0r" path="res://Ball/Meshes/ball_material.tres" id="1_5n3i6"]
[ext_resource type="Script" path="res://Ball/ball_test.gd" id="1_s3xmr"]
[sub_resource type="SphereShape3D" id="SphereShape3D_jblqj"]
radius = 0.1
[sub_resource type="SphereMesh" id="SphereMesh_52mtx"]
[sub_resource type="SphereShape3D" id="SphereShape3D_862wy"]
[sub_resource type="SphereShape3D" id="SphereShape3D_dwt7q"]
[sub_resource type="BoxMesh" id="BoxMesh_1auv0"]
[sub_resource type="SphereMesh" id="SphereMesh_xquva"]
radius = 0.2
height = 0.4
[sub_resource type="SphereMesh" id="SphereMesh_bnhf3"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_5h0ki"]
transparency = 1
albedo_color = Color(1, 0.372549, 1, 0.701961)
[node name="BallBase" type="RigidBody3D"]
collision_layer = 0
collision_mask = 0
gravity_scale = 0.0
continuous_cd = true
lock_rotation = true
linear_damp_mode = 1
angular_damp_mode = 1
script = ExtResource("1_s3xmr")
speed = 20.0
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_jblqj")
[node name="BallMesh" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.0029127)
mesh = SubResource("SphereMesh_52mtx")
surface_material_override/0 = ExtResource("1_5n3i6")
[node name="BallBody" type="StaticBody3D" parent="."]
collision_layer = 4
collision_mask = 5
[node name="CollisionShape3D" type="CollisionShape3D" parent="BallBody"]
shape = SubResource("SphereShape3D_862wy")
[node name="AnchorBody3D" type="StaticBody3D" parent="."]
top_level = true
collision_layer = 4
collision_mask = 5
[node name="CollisionShape3D" type="CollisionShape3D" parent="AnchorBody3D"]
shape = SubResource("SphereShape3D_dwt7q")
[node name="MeshInstance3D" type="MeshInstance3D" parent="AnchorBody3D"]
mesh = SubResource("BoxMesh_1auv0")
[node name="TestMesh" type="MeshInstance3D" parent="."]
visible = false
mesh = SubResource("SphereMesh_xquva")
[node name="TestMesh2" type="MeshInstance3D" parent="."]
visible = false
mesh = SubResource("SphereMesh_bnhf3")
surface_material_override/0 = SubResource("StandardMaterial3D_5h0ki")

49
Ball/ball_test.gd Normal file
View File

@ -0,0 +1,49 @@
extends RigidBody3D
@onready var mesh = $BallMesh
@onready var body = $BallBody
@onready var body_anchor = $AnchorBody
@export var speed : float
@export var gravity : Vector3
@export var stiffness : float
var previous_collision_normal_array = []
var normalize_velocity = true
var previous_travel : Vector3
func _ready():
body.add_collision_exception_with(body_anchor)
body_anchor.add_collision_exception_with(body)
linear_velocity = linear_velocity.normalized() * speed
# Engine.time_scale = 1
func _physics_process(delta):
if global_position.length() >= 100:
print("a")
queue_free()
var collision : KinematicCollision3D = body.move_and_collide(linear_velocity * delta, true)
if collision:
var collision_position = collision.get_position()
$TestMesh.global_position = collision_position
mesh.look_at($TestMesh.global_position, Vector3.UP)
if collision.get_collider().owner.is_in_group("balls"):
mesh.scale.z = (global_position - collision.get_collider().global_position).length()
else:
mesh.scale.z = (collision_position - global_position).length() * 2
mesh.scale.x = 1.5 - mesh.scale.z / 2
mesh.scale.y = 1.5 - mesh.scale.z / 2
# var current_travel = collision.get_travel().normalized()
# linear_velocity += current_travel * pow(speed, 2) * delta
# normalize_velocity = false
else:
mesh.scale = Vector3.ONE
linear_velocity = linear_velocity.normalized() * speed
constant_force = gravity + (body_anchor.global_position - global_position) * 10 * pow(speed, 2)
body_anchor.velocity = linear_velocity
body_anchor.move_and_slide()

72
Ball/ball_test.tscn Normal file
View File

@ -0,0 +1,72 @@
[gd_scene load_steps=11 format=3 uid="uid://dd1e3u5cyy3mk"]
[ext_resource type="Material" uid="uid://ccktnp41cys0r" path="res://Ball/Meshes/ball_material.tres" id="1_5n3i6"]
[ext_resource type="Script" path="res://Ball/ball_test.gd" id="1_s3xmr"]
[sub_resource type="SphereShape3D" id="SphereShape3D_jblqj"]
radius = 0.1
[sub_resource type="SphereMesh" id="SphereMesh_52mtx"]
[sub_resource type="SphereShape3D" id="SphereShape3D_862wy"]
[sub_resource type="SphereShape3D" id="SphereShape3D_dwt7q"]
[sub_resource type="BoxMesh" id="BoxMesh_1auv0"]
[sub_resource type="SphereMesh" id="SphereMesh_xquva"]
radius = 0.2
height = 0.4
[sub_resource type="SphereMesh" id="SphereMesh_bnhf3"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_5h0ki"]
transparency = 1
albedo_color = Color(1, 0.372549, 1, 0.701961)
[node name="BallBase" type="RigidBody3D" groups=["balls"]]
collision_layer = 0
collision_mask = 0
gravity_scale = 0.0
continuous_cd = true
lock_rotation = true
linear_damp_mode = 1
angular_damp_mode = 1
script = ExtResource("1_s3xmr")
speed = 10.0
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_jblqj")
[node name="BallMesh" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.0029127)
mesh = SubResource("SphereMesh_52mtx")
surface_material_override/0 = ExtResource("1_5n3i6")
[node name="BallBody" type="StaticBody3D" parent="."]
collision_layer = 4
collision_mask = 5
[node name="CollisionShape3D" type="CollisionShape3D" parent="BallBody"]
shape = SubResource("SphereShape3D_862wy")
[node name="AnchorBody" type="CharacterBody3D" parent="."]
top_level = true
collision_layer = 8
collision_mask = 9
[node name="CollisionShape3D" type="CollisionShape3D" parent="AnchorBody"]
shape = SubResource("SphereShape3D_dwt7q")
[node name="MeshInstance3D" type="MeshInstance3D" parent="AnchorBody"]
visible = false
mesh = SubResource("BoxMesh_1auv0")
[node name="TestMesh" type="MeshInstance3D" parent="."]
visible = false
mesh = SubResource("SphereMesh_xquva")
[node name="TestMesh2" type="MeshInstance3D" parent="."]
visible = false
mesh = SubResource("SphereMesh_bnhf3")
surface_material_override/0 = SubResource("StandardMaterial3D_5h0ki")

View File

@ -1,7 +1,7 @@
extends CharacterBody3D
const SPEED = 5.0
const SPEED = 50.0
const JUMP_VELOCITY = 4.5
# Get the gravity from the project settings to be synced with RigidBody nodes.

View File

@ -3,7 +3,7 @@
[ext_resource type="Script" path="res://Player/player.gd" id="1_f70jf"]
[ext_resource type="Script" path="res://Player/player_camera_basis.gd" id="2_o7m3c"]
[ext_resource type="Script" path="res://Player/shooter.gd" id="3_eijnn"]
[ext_resource type="PackedScene" uid="uid://rdlvlyf0l1l" path="res://Ball/ball.tscn" id="4_5tvf6"]
[ext_resource type="PackedScene" uid="uid://dd1e3u5cyy3mk" path="res://Ball/ball_test.tscn" id="4_rdfyn"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_v066f"]
radius = 0.35
@ -31,4 +31,4 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1)
[node name="Shooter" type="Node3D" parent="Camera"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.5)
script = ExtResource("3_eijnn")
ball_scene = ExtResource("4_5tvf6")
ball_scene = ExtResource("4_rdfyn")

View File

@ -2,9 +2,12 @@ extends Node3D
@export var ball_scene : PackedScene
var count = 0
func shoot(spawn_position ,direction = Vector3.FORWARD, strength = 7):
count += 1
print(count)
var ball = ball_scene.instantiate()
ball.linear_velocity = direction * strength

View File

@ -1,10 +1,11 @@
[gd_scene load_steps=10 format=3 uid="uid://b06nx3ofndgjy"]
[gd_scene load_steps=11 format=3 uid="uid://b06nx3ofndgjy"]
[ext_resource type="Texture2D" uid="uid://onahsd5he406" path="res://Misc/64x64_orange_grey.png" id="1_k0u6d"]
[ext_resource type="PackedScene" uid="uid://ggl4tqcb5dbc" path="res://Player/player.tscn" id="1_n0nhi"]
[ext_resource type="Script" path="res://Misc/debug_cone.gd" id="3_nsiny"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_bwr1w"]
albedo_color = Color(1, 1, 1, 0.882353)
albedo_texture = ExtResource("1_k0u6d")
uv1_scale = Vector3(0.5, 0.5, 0.5)
uv1_triplanar = true
@ -20,6 +21,10 @@ points = PackedVector3Array(1.5, 0, 4, -1.5, 0, 4, 1.5, 0, -4, -1.5, 0, -4)
radius = 3.0
height = 6.0
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_587aa"]
transparency = 1
albedo_color = Color(0.619608, 1, 0.67451, 0.678431)
[sub_resource type="SphereShape3D" id="SphereShape3D_hjh1m"]
radius = 3.0
@ -54,10 +59,11 @@ transform = Transform3D(0.707107, 0.707107, -3.09086e-08, 0, -4.37114e-08, -1, -
shape = SubResource("ConvexPolygonShape3D_iauoa")
[node name="Sphere" type="StaticBody3D" parent="Level"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 0, -6)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.736659, 2.85172, -3.29585)
[node name="MeshInstance3D" type="MeshInstance3D" parent="Level/Sphere"]
mesh = SubResource("SphereMesh_0a0pq")
surface_material_override/0 = SubResource("StandardMaterial3D_587aa")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Level/Sphere"]
shape = SubResource("SphereShape3D_hjh1m")

View File

@ -54,3 +54,4 @@ shoot={
3d_physics/layer_1="general"
3d_physics/layer_2="player"
3d_physics/layer_3="balls"
3d_physics/layer_4="anchors"