[gd_scene load_steps=11 format=3 uid="uid://cnnvwotv33u1b"] [sub_resource type="GDScript" id="GDScript_bnqcw"] script/source = "class_name Player extends Node3D signal velocity_change var velocity := 0.0: get: return velocity set(value): if value != velocity: velocity_change.emit(value) velocity = value func _physics_process(_delta: float) -> void: $SpotLightMain.position = $Sphere.position + Vector3(0, 5, 0) $SpotLightTop.position = $Sphere.position $SpotLightLeft.position = $Sphere.position $SpotLightRight.position = $Sphere.position $SpotLightBottom.position = $Sphere.position # Keep the ball at the center of the camera, at a distance $Camera.position = $Sphere.position + Vector3(0, 0, 15) # Angle of the camera, so the player can see where the ball is going velocity = abs($Sphere.linear_velocity.x) + abs($Sphere.linear_velocity.y) var desired_x = max(min($Sphere.linear_velocity.y, 35), -35) var desired_y = max(min(-$Sphere.linear_velocity.x, 50), -50) var difference_x = $Camera.rotation_degrees.x - desired_x var difference_y = $Camera.rotation_degrees.y - desired_y $Camera.rotation_degrees.x -= max(min(difference_x / 2, 3), -3) $Camera.rotation_degrees.y -= max(min(difference_y / 2, 3), -3) # FOV of the camera, so it unzooms more at higher velocities const default_fov = 75 $Camera.fov = default_fov + (velocity / 12) " [sub_resource type="PhysicsMaterial" id="PhysicsMaterial_vumbr"] bounce = 0.2 [sub_resource type="SphereShape3D" id="SphereShape3D_xfgrm"] [sub_resource type="Gradient" id="Gradient_bgp4x"] colors = PackedColorArray(0.942957, 7.89344e-06, 0.597148, 1, 0, 0.9912, 0.9912, 1) [sub_resource type="GradientTexture2D" id="GradientTexture2D_5d6uk"] gradient = SubResource("Gradient_bgp4x") fill_from = Vector2(0.504951, 0.00495049) fill_to = Vector2(0.549505, 1) [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_qcgmu"] albedo_texture = SubResource("GradientTexture2D_5d6uk") [sub_resource type="SphereMesh" id="SphereMesh_bor8g"] material = SubResource("StandardMaterial3D_qcgmu") [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_4tofj"] direction = Vector3(0, 0, 0) gravity = Vector3(0, 0, 0) [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_2ybet"] vertex_color_use_as_albedo = true albedo_color = Color(0, 0.734117, 0.734117, 1) [sub_resource type="SphereMesh" id="SphereMesh_1m3ut"] material = SubResource("StandardMaterial3D_2ybet") radius = 0.2 height = 0.4 radial_segments = 8 rings = 4 [node name="Player" type="Node3D"] script = SubResource("GDScript_bnqcw") [node name="Camera" type="Camera3D" parent="."] current = true [node name="SpotLightMain" type="SpotLight3D" parent="."] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0) spot_range = 55.0 spot_angle = 20.0 [node name="SpotLightTop" type="SpotLight3D" parent="."] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0) spot_range = 50.0 [node name="SpotLightLeft" type="SpotLight3D" parent="."] transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0) spot_range = 50.0 [node name="SpotLightRight" type="SpotLight3D" parent="."] transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 0, 0) spot_range = 50.0 [node name="SpotLightBottom" type="SpotLight3D" parent="."] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0) spot_range = 50.0 [node name="Sphere" type="RigidBody3D" parent="."] collision_priority = 100.0 axis_lock_linear_z = true physics_material_override = SubResource("PhysicsMaterial_vumbr") can_sleep = false contact_monitor = true [node name="CollisionShape3D" type="CollisionShape3D" parent="Sphere"] shape = SubResource("SphereShape3D_xfgrm") [node name="MeshInstance3D" type="MeshInstance3D" parent="Sphere"] mesh = SubResource("SphereMesh_bor8g") [node name="GPUParticles3D" type="GPUParticles3D" parent="Sphere"] amount = 16 process_material = SubResource("ParticleProcessMaterial_4tofj") draw_pass_1 = SubResource("SphereMesh_1m3ut")