65 lines
2.5 KiB
Text
65 lines
2.5 KiB
Text
[gd_scene load_steps=4 format=3 uid="uid://cnnvwotv33u1b"]
|
|
|
|
[ext_resource type="PackedScene" uid="uid://dw0xl8644x166" path="res://elements/gravity.tscn" id="1_h0h2o"]
|
|
[ext_resource type="PackedScene" uid="uid://df5m716pd6mej" path="res://elements/sphere.tscn" id="2_ophnk"]
|
|
|
|
[sub_resource type="GDScript" id="GDScript_bnqcw"]
|
|
script/source = "extends Node3D
|
|
|
|
func _process(_delta: float) -> void:
|
|
#if $Sphere.position.y < -2:
|
|
# $Sphere.position.y = 0
|
|
$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
|
|
var velocity: Vector3 = $Sphere.linear_velocity
|
|
var desired_x = max(min(velocity.y / 2, 20), -20)
|
|
var desired_y = max(min(-velocity.x / 2, 45), -45)
|
|
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 / 4, 3), -3)
|
|
$Camera.rotation_degrees.y -= max(min(difference_y / 4, 3), -3)
|
|
|
|
## FOV of the camera, so it unzooms more at higher velocities
|
|
const default_fov = 75
|
|
var total_velocity = abs(velocity.x) + abs(velocity.y)
|
|
$Camera.fov = default_fov + (total_velocity / 12)
|
|
"
|
|
|
|
[node name="Player" type="Node3D"]
|
|
script = SubResource("GDScript_bnqcw")
|
|
|
|
[node name="Gravity" parent="." instance=ExtResource("1_h0h2o")]
|
|
|
|
[node name="Sphere" parent="." instance=ExtResource("2_ophnk")]
|
|
|
|
[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
|