diff --git a/Ball/Meshes/ball_material.tres b/Ball/Meshes/ball_material.tres index 176674e..54333a3 100644 --- a/Ball/Meshes/ball_material.tres +++ b/Ball/Meshes/ball_material.tres @@ -7,5 +7,5 @@ render_priority = 0 shader = ExtResource("1_kfvtm") shader_parameter/intensity = 1.0 -shader_parameter/color = Color(0.333333, 0.545098, 0.976471, 0.862745) +shader_parameter/color = Color(0.333333, 0.545098, 0.976471, 1) shader_parameter/matcap = ExtResource("2_o5lk5") diff --git a/Ball/Meshes/ball_shader.gdshader b/Ball/Meshes/ball_shader.gdshader index fa6b558..9e296d6 100644 --- a/Ball/Meshes/ball_shader.gdshader +++ b/Ball/Meshes/ball_shader.gdshader @@ -14,5 +14,4 @@ void fragment() { vec2 matcap_uv = (NORMAL.xy * vec2(0.5, -0.5) + vec2(0.5, 0.5)); ALBEDO = color.rgb; ALBEDO *= mix(vec3(1.0), texture(matcap, matcap_uv).rgb, intensity); - ALPHA = color.a; } \ No newline at end of file diff --git a/Ball/Meshes/ball_tail.glb b/Ball/Meshes/ball_tail.glb index 3e842df..a1b22c5 100644 Binary files a/Ball/Meshes/ball_tail.glb and b/Ball/Meshes/ball_tail.glb differ diff --git a/Ball/Meshes/ball_tail.glb.import b/Ball/Meshes/ball_tail.glb.import index 31c8087..e366ca7 100644 --- a/Ball/Meshes/ball_tail.glb.import +++ b/Ball/Meshes/ball_tail.glb.import @@ -3,7 +3,7 @@ importer="scene" importer_version=1 type="PackedScene" -uid="uid://bvnuni6qjuvt4" +uid="uid://ctsvwwopru2jf" path="res://.godot/imported/ball_tail.glb-e1c9b3c5d2a8f19476283eb997d8e59c.scn" [deps] @@ -28,5 +28,12 @@ animation/fps=30 animation/trimming=false animation/remove_immutable_tracks=true import_script/path="" -_subresources={} +_subresources={ +"materials": { +"Ball": { +"use_external/enabled": true, +"use_external/path": "res://Ball/Meshes/ball_material.tres" +} +} +} gltf/embedded_image_handling=1 diff --git a/Ball/ball_tail_mesh.gd b/Ball/ball_tail_mesh.gd new file mode 100644 index 0000000..84d0a56 --- /dev/null +++ b/Ball/ball_tail_mesh.gd @@ -0,0 +1,20 @@ +extends Node3D + + +@onready var ball = owner +@onready var mesh = get_node("tail") + + +func _process(delta): + # Align the tail to the linear velocity + look_at(ball.linear_velocity + ball.global_position) + + shrink_tail() + + +func shrink_tail(): + # Set the blend shape value to how much the ball is squished + # A power of 0.5 makes the shrinking effect more apparent + var factor = pow((1 - ball.mesh.scale.z), 0.5) + var blend_shape = mesh.find_blend_shape_by_name("Shrink") + mesh.set_blend_shape_value(blend_shape, factor) diff --git a/Ball/ball_test.gd b/Ball/ball_test.gd index 368338e..aae10e6 100644 --- a/Ball/ball_test.gd +++ b/Ball/ball_test.gd @@ -11,7 +11,9 @@ extends RigidBody3D func _ready(): linear_velocity = linear_velocity.normalized() * speed - DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN) + +# DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN) + func _physics_process(delta): if global_position.length() >= 100: @@ -33,7 +35,7 @@ func _physics_process(delta): mesh.scale.y = scalexy else: mesh.scale = Vector3.ONE - + # Physics body_anchor.velocity = (global_position - body_anchor.global_position).normalized() * speed if not body_anchor.move_and_slide(): diff --git a/Ball/ball_test.tscn b/Ball/ball_test.tscn index abd0398..d11dfbb 100644 --- a/Ball/ball_test.tscn +++ b/Ball/ball_test.tscn @@ -1,7 +1,9 @@ -[gd_scene load_steps=7 format=3 uid="uid://dd1e3u5cyy3mk"] +[gd_scene load_steps=9 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"] +[ext_resource type="PackedScene" uid="uid://ctsvwwopru2jf" path="res://Ball/Meshes/ball_tail.glb" id="3_s5l2d"] +[ext_resource type="Script" path="res://Ball/ball_tail_mesh.gd" id="4_vur1t"] [sub_resource type="SphereShape3D" id="SphereShape3D_jblqj"] radius = 0.1 @@ -20,9 +22,9 @@ lock_rotation = true linear_damp_mode = 1 angular_damp_mode = 1 script = ExtResource("1_s3xmr") -speed = 10.0 -gravity = Vector3(0, -10, 0) -stiffness = 10.0 +speed = 5.0 +gravity = Vector3(0, -1, 0) +stiffness = 5.0 [node name="CollisionShape3D" type="CollisionShape3D" parent="."] shape = SubResource("SphereShape3D_jblqj") @@ -32,6 +34,9 @@ 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="TailMesh" parent="BallMesh" instance=ExtResource("3_s5l2d")] +script = ExtResource("4_vur1t") + [node name="BallBody" type="StaticBody3D" parent="."] collision_layer = 4 collision_mask = 5 diff --git a/Player/player.gd b/Player/player.gd index 3676080..af7be92 100644 --- a/Player/player.gd +++ b/Player/player.gd @@ -1,7 +1,7 @@ extends CharacterBody3D -const SPEED = 50.0 +const SPEED = 10.0 const JUMP_VELOCITY = 4.5 # Get the gravity from the project settings to be synced with RigidBody nodes.