added picture spots and basic follow path

This commit is contained in:
LaptopmanMann 2025-09-16 16:49:17 +02:00
parent 1cbf223ad5
commit 101dd3d5fc
20 changed files with 115 additions and 41 deletions

View file

@ -1,18 +1,10 @@
[gd_scene load_steps=4 format=3 uid="uid://xa3ee14whqj6"] [gd_scene load_steps=3 format=3 uid="uid://ctj6v4t55qr61"]
[ext_resource type="PackedScene" uid="uid://c8gnb0kut2n5h" path="res://Florian/point_thing.tscn" id="1_ths60"] [ext_resource type="Script" uid="uid://bgolfgrq66diw" path="res://npc_path_follower.gd" id="1_f6meo"]
[ext_resource type="Texture2D" uid="uid://b3y733ngio1nx" path="res://Florian/Sprites/cat.jpg" id="2_f6meo"] [ext_resource type="PackedScene" uid="uid://c8gnb0kut2n5h" path="res://Florian/PointsLogic/point_thing.tscn" id="1_ths60"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_vea6b"] [node name="Cat" type="PathFollow3D"]
script = ExtResource("1_f6meo")
[node name="Cat" type="RigidBody3D"] metadata/_custom_type_script = "uid://bgolfgrq66diw"
[node name="PointThing" parent="." instance=ExtResource("1_ths60")] [node name="PointThing" parent="." instance=ExtResource("1_ths60")]
[node name="Sprite3D" type="Sprite3D" parent="."]
texture = ExtResource("2_f6meo")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("CapsuleShape3D_vea6b")
[node name="PathFollow3D" type="PathFollow3D" parent="."]

View file

@ -1,7 +1,7 @@
[gd_scene load_steps=6 format=3 uid="uid://crrco762ow56c"] [gd_scene load_steps=6 format=3 uid="uid://crrco762ow56c"]
[ext_resource type="Script" uid="uid://c35h32dniya44" path="res://Florian/playerRigidbody.gd" id="1_7u3v3"] [ext_resource type="Script" uid="uid://c35h32dniya44" path="res://Florian/Player/playerRigidbody.gd" id="1_7u3v3"]
[ext_resource type="PackedScene" uid="uid://4hac7s0wvoye" path="res://Florian/cool_camera.tscn" id="2_leq5j"] [ext_resource type="PackedScene" uid="uid://4hac7s0wvoye" path="res://Florian/Player/cool_camera.tscn" id="2_leq5j"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_jbuyh"] [sub_resource type="PhysicsMaterial" id="PhysicsMaterial_jbuyh"]
friction = 0.0 friction = 0.0
@ -36,7 +36,8 @@ collide_with_areas = true
collide_with_bodies = false collide_with_bodies = false
debug_shape_thickness = 1 debug_shape_thickness = 1
[node name="CoolCamera" parent="BoundingBox/RotationHelper" instance=ExtResource("2_leq5j")] [node name="CoolCamera" parent="BoundingBox/RotationHelper" node_paths=PackedStringArray("player") instance=ExtResource("2_leq5j")]
player = NodePath("../../..")
[node name="ThirdPerson" type="Node3D" parent="BoundingBox"] [node name="ThirdPerson" type="Node3D" parent="BoundingBox"]
transform = Transform3D(1, 0, 0, 0, 0.965926, 0.258819, 0, -0.258819, 0.965926, 0, 1.94907, 3) transform = Transform3D(1, 0, 0, 0, 0.965926, 0.258819, 0, -0.258819, 0.965926, 0, 1.94907, 3)

View file

@ -0,0 +1,39 @@
extends Node3D
@onready var label: Label = $Control/Label
@export var player : PlayerRB = null
func _input(event: InputEvent) -> void:
if event.is_action_pressed("take_picture"):
_take_picture()
func _take_picture():
_calculate_points()
pass
var points_string = ""
var total_points = 0
var total_points_multipliers = 1
func _calculate_points():
points_string = ""
total_points = 0
total_points_multipliers = 1
print("Taking Picture!!!")
_calculate_picture_objects()
_calculate_picture_spots()
label.text = "%s\nTotal points: %d x %.2f = %.2f" % [points_string, total_points, total_points_multipliers, total_points * total_points_multipliers]
func _calculate_picture_objects():
for takeable in PictureTakeablesArray.picture_takables:
print("Checking takeable")
if takeable.picture_taken():
points_string += "{name} {points}\n".format({"name" : takeable.points_name, "points": str(takeable.points_worth)})
total_points += takeable.points_worth
total_points_multipliers *= takeable.points_multiplier
func _calculate_picture_spots():
for spot in PictureTakeablesArray.picture_spots:
if spot.picture_taken(player):
points_string += "{name} {points}\n".format({"name" : spot.points_name, "points": str(spot.points_worth)})
total_points += spot.points_worth
total_points_multipliers *= spot.points_multiplier

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://4hac7s0wvoye"] [gd_scene load_steps=2 format=3 uid="uid://4hac7s0wvoye"]
[ext_resource type="Script" uid="uid://dff1mtnypemb4" path="res://Florian/cool_camera.gd" id="1_87r7f"] [ext_resource type="Script" uid="uid://dff1mtnypemb4" path="res://Florian/Player/cool_camera.gd" id="1_87r7f"]
[node name="CoolCamera" type="Node3D"] [node name="CoolCamera" type="Node3D"]
script = ExtResource("1_87r7f") script = ExtResource("1_87r7f")

View file

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://bw73kprk7ptvn"]
[ext_resource type="Script" uid="uid://44ieb2gc6uff" path="res://Florian/PointsLogic/picture_spot.gd" id="1_r37ay"]
[node name="PictureSpot" type="Area3D"]
script = ExtResource("1_r37ay")

View file

@ -0,0 +1,15 @@
class_name PictureSpot
extends Area3D
@export var points_multiplier := 1
@export var points_worth := 10
@export var points_name := "Debug Points Area"
func _ready() -> void:
PictureTakeablesArray._add_picture_spot(self)
func picture_taken(player: PlayerRB) -> bool:
var bodies = get_overlapping_bodies()
if player in bodies:
return true
return false

View file

@ -0,0 +1 @@
uid://44ieb2gc6uff

View file

@ -3,8 +3,9 @@ extends Node3D
@onready var red_circle: Sprite3D = $RedCircle @onready var red_circle: Sprite3D = $RedCircle
@onready var on_screen: VisibleOnScreenNotifier3D = $VisibleOnScreenNotifier3D @onready var on_screen: VisibleOnScreenNotifier3D = $VisibleOnScreenNotifier3D
@export var points_worth = 10 @export var points_worth : int= 10
@export var point_id = "Debug Object" @export var points_name = "Debug Object"
@export var points_multiplier : float = 1
func _ready() -> void: func _ready() -> void:
PictureTakeablesArray._add_point_picture(self) PictureTakeablesArray._add_point_picture(self)

View file

@ -1,6 +1,6 @@
[gd_scene load_steps=4 format=3 uid="uid://c8gnb0kut2n5h"] [gd_scene load_steps=4 format=3 uid="uid://c8gnb0kut2n5h"]
[ext_resource type="Script" uid="uid://cyw0eu5pqd3wm" path="res://Florian/point_thing.gd" id="1_hr556"] [ext_resource type="Script" uid="uid://cyw0eu5pqd3wm" path="res://Florian/PointsLogic/point_thing.gd" id="1_hr556"]
[ext_resource type="Texture2D" uid="uid://bpqf3a8f2fp7q" path="res://Florian/Sprites/red_circle.png" id="2_wfrpx"] [ext_resource type="Texture2D" uid="uid://bpqf3a8f2fp7q" path="res://Florian/Sprites/red_circle.png" id="2_wfrpx"]
[sub_resource type="BoxMesh" id="BoxMesh_hr556"] [sub_resource type="BoxMesh" id="BoxMesh_hr556"]

View file

@ -1,14 +0,0 @@
extends Node3D
@onready var label: Label = $Control/Label
func _input(event: InputEvent) -> void:
if event.is_action_pressed("take_picture"):
print("Taking Picture!!!")
var points_string = ""
var total_points = 0
for takeable in PictureTakeablesArray.picture_takables:
print("Checking takeable")
if takeable.picture_taken():
points_string += "%s %d\n" % [str(takeable.point_id), int(takeable.points_worth)]
total_points += takeable.points_worth
label.text = "%s\nTotal points: %d" % [points_string, total_points]

View file

@ -3,25 +3,26 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://dv401srtwuvtg" uid="uid://dv401srtwuvtg"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" path.s3tc="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"
metadata={ metadata={
"vram_texture": false "imported_formats": ["s3tc_bptc"],
"vram_texture": true
} }
[deps] [deps]
source_file="res://icon.svg" source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"]
[params] [params]
compress/mode=0 compress/mode=2
compress/high_quality=false compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/hdr_compression=1 compress/hdr_compression=1
compress/normal_map=0 compress/normal_map=0
compress/channel_pack=0 compress/channel_pack=0
mipmaps/generate=false mipmaps/generate=true
mipmaps/limit=-1 mipmaps/limit=-1
roughness/mode=0 roughness/mode=0
roughness/src_normal="" roughness/src_normal=""
@ -31,7 +32,7 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false process/hdr_as_srgb=false
process/hdr_clamp_exposure=false process/hdr_clamp_exposure=false
process/size_limit=0 process/size_limit=0
detect_3d/compress_to=1 detect_3d/compress_to=0
svg/scale=1.0 svg/scale=1.0
editor/scale_with_editor_scale=false editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false editor/convert_colors_with_editor_theme=false

17
npc_path_follower.gd Normal file
View file

@ -0,0 +1,17 @@
class_name NPCPathFollower
extends PathFollow3D
@export var speed = 3
@export var path : Path3D = null
func _ready():
if path == null:
path = get_parent()
func _process(delta: float):
# Move along the path
self.progress += speed * delta
# Loop the path if we reach the end
if self.progress >= path.curve.get_baked_length():
self.progress = 0

1
npc_path_follower.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://bgolfgrq66diw

6
npc_path_follower.tscn Normal file
View file

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://snif6gs2ssjr"]
[ext_resource type="Script" uid="uid://bgolfgrq66diw" path="res://npc_path_follower.gd" id="1_ihrgw"]
[node name="NPCPathFollower" type="PathFollow3D"]
script = ExtResource("1_ihrgw")

View file

@ -1,3 +1,6 @@
extends Node extends Node
@export var path_3d_array : Array[Path3D] = [] @export var path_3d_array : Array[Path3D] = []
func add_path(path: Path3D):
path_3d_array.append(path)

View file

@ -1,8 +1,13 @@
extends Node extends Node
var picture_takables : Array[PointPicture] = [] var picture_takables : Array[PointPicture] = []
var picture_spots: Array[PictureSpot] = []
func _add_point_picture(point_picture: PointPicture): func _add_point_picture(point_picture: PointPicture):
print("Adding picture takeable") print("Adding picture takeable")
picture_takables.append(point_picture) picture_takables.append(point_picture)
print(len(picture_takables)) print(len(picture_takables))
func _add_picture_spot(picture_spot: PictureSpot):
print("Adding picture Spot")
picture_spots.append(picture_spot)