pull/19/head
Kenney 2024-07-04 19:00:22 +07:00
parent 7981d9f283
commit f51aa62615
5 changed files with 189 additions and 11 deletions

@ -2,7 +2,7 @@
# Starter Kit 3D Platformer
This package includes a basic template for a 3D platformer game in Godot 4.1.1.stable.official. Includes features like;
This package includes a basic template for a 3D platformer game in Godot 4.2.2.stable.official. Includes features like;
- Character controller (with double jump)
- Collectable coins and falling platforms
@ -19,7 +19,7 @@ This package includes a basic template for a 3D platformer game in Godot 4.1.1.s
MIT License
Copyright (c) 2023 Kenney
Copyright (c) 2024 Kenney
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@ -11,13 +11,16 @@ transform = Transform3D(0.965926, 0, 0.258819, 0, 1, 0, -0.258819, 0, 0.965926,
transform = Transform3D(0.965926, 0, -0.258819, 0, 1, 0, 0.258819, 0, 0.965926, -0.125, 0.17625, -0.02375)
[node name="torso" parent="character/root" index="2"]
transform = Transform3D(1, 0, 0, 0, 0.99766, 0.0683636, 0, -0.0683636, 0.99766, -1.80478e-15, 0.17625, -0.02375)
transform = Transform3D(1, 0, 0, 0, 0.996194, 0.0871557, 0, -0.0871557, 0.996194, -1.80478e-15, 0.17625, -0.02375)
[node name="arm-left" parent="character/root/torso" index="0"]
transform = Transform3D(0.745941, 0.666012, 0, -0.666012, 0.745941, 0, 0, 0, 1, 0.3, 0.175, 0)
transform = Transform3D(0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 0, 0, 1, 0.3, 0.175, 0)
[node name="arm-right" parent="character/root/torso" index="1"]
transform = Transform3D(0.745941, -0.666012, 0, 0.666012, 0.745941, 0, 0, 0, 1, -0.3, 0.1195, 0)
transform = Transform3D(0.707107, -0.707107, 0, 0.707107, 0.707107, 0, 0, 0, 1, -0.3, 0.1195, 0)
[node name="antenna" parent="character/root/torso" index="2"]
transform = Transform3D(1, 0, 0, 0, 0.999289, 0.0376902, 0, -0.0376902, 0.999289, 0, 0.6, 0)
transform = Transform3D(1, 0, 0, 0, 0.999999, 0, 0, 0, 0.999999, 0, 0.6, 0)
[node name="AnimationPlayer" parent="." index="1"]
deterministic = true

@ -33,8 +33,17 @@ shape = SubResource("CapsuleShape3D_gdq8c")
[node name="Character" parent="." instance=ExtResource("2_nero3")]
[node name="torso" parent="Character/character/root" index="2"]
transform = Transform3D(1, 0, 0, 0, 0.996194, 0.0871557, 0, -0.0871557, 0.996194, -1.80478e-15, 0.17625, -0.02375)
[node name="arm-left" parent="Character/character/root/torso" index="0"]
transform = Transform3D(0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 0, 0, 1, 0.3, 0.175, 0)
[node name="arm-right" parent="Character/character/root/torso" index="1"]
transform = Transform3D(0.707107, -0.707107, 0, 0.707107, 0.707107, 0, 0, 0, 1, -0.3, 0.1195, 0)
[node name="antenna" parent="Character/character/root/torso" index="2"]
transform = Transform3D(1, 0, 0, 0, 0.999289, 0.0376902, 0, -0.0376902, 0.999289, 0, 0.6, 0)
transform = Transform3D(1, 0, 0, 0, 0.999999, 0, 0, 0, 0.999999, 0, 0.6, 0)
[node name="Shadow" type="Decal" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.9, 0)

@ -0,0 +1,165 @@
[gd_scene load_steps=15 format=3 uid="uid://bqqgyqafm7xwp"]
[ext_resource type="Environment" uid="uid://bqnqgflivjvue" path="res://scenes/main-environment.tres" id="1_ahusb"]
[ext_resource type="PackedScene" uid="uid://dl2ed4gkybggf" path="res://objects/player.tscn" id="2_onms2"]
[ext_resource type="Script" path="res://scripts/view.gd" id="5_bg0fr"]
[ext_resource type="PackedScene" uid="uid://cnymdajj1vsqm" path="res://objects/platform.tscn" id="6_sdmev"]
[ext_resource type="PackedScene" uid="uid://rjh4ifidqrfp" path="res://objects/platform_medium.tscn" id="7_ixpj3"]
[ext_resource type="PackedScene" uid="uid://uqr4hswv6d2g" path="res://objects/platform_grass_large_round.tscn" id="8_4oh1e"]
[ext_resource type="PackedScene" uid="uid://c8up71en5djgm" path="res://objects/platform_falling.tscn" id="9_2fnpo"]
[ext_resource type="PackedScene" uid="uid://dtjvjdjl8cs6e" path="res://models/flag.glb" id="9_fw1f5"]
[ext_resource type="PackedScene" uid="uid://dfpisimsgf5ce" path="res://objects/coin.tscn" id="10_fwhys"]
[ext_resource type="Script" path="res://scripts/hud.gd" id="11_apvpm"]
[ext_resource type="PackedScene" uid="uid://dy017k58p20sk" path="res://objects/cloud.tscn" id="13_drtpy"]
[ext_resource type="Texture2D" uid="uid://cd7oyc56ehkx1" path="res://sprites/coin.png" id="13_jfda3"]
[ext_resource type="FontFile" uid="uid://d0cxd77jybrcn" path="res://fonts/lilita_one_regular.ttf" id="17_tk810"]
[sub_resource type="LabelSettings" id="LabelSettings_38ys3"]
font = ExtResource("17_tk810")
font_size = 48
shadow_color = Color(0, 0, 0, 0.376471)
shadow_offset = Vector2(2, 2)
[node name="Main" type="Node3D"]
[node name="Environment" type="WorldEnvironment" parent="."]
environment = ExtResource("1_ahusb")
[node name="Player" parent="." node_paths=PackedStringArray("view") instance=ExtResource("2_onms2")]
view = NodePath("../View")
[node name="View" type="Node3D" parent="." node_paths=PackedStringArray("target")]
transform = Transform3D(0.707107, -0.298836, 0.640856, 0, 0.906308, 0.422618, -0.707107, -0.298836, 0.640856, 0, 0, 0)
script = ExtResource("5_bg0fr")
target = NodePath("../Player")
[node name="Camera" type="Camera3D" parent="View"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 10)
current = true
fov = 40.0
[node name="World" type="Node3D" parent="."]
[node name="platform" parent="World" instance=ExtResource("6_sdmev")]
transform = Transform3D(0.993085, 0, -0.117399, 0, 1, 0, 0.117399, 0, 0.993085, 0, 0, 0)
[node name="platform4" parent="World" instance=ExtResource("6_sdmev")]
transform = Transform3D(0.993085, 0, -0.117399, 0, 1, 0, 0.117399, 0, 0.993085, -15, 0, 4)
[node name="platform2" parent="World" instance=ExtResource("6_sdmev")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 2, -3)
[node name="platform3" parent="World" instance=ExtResource("6_sdmev")]
transform = Transform3D(0.966237, 0, -0.257656, 0, 1, 0, 0.257656, 0, 0.966237, -3, 3, -5)
[node name="platform-medium" parent="World" instance=ExtResource("7_ixpj3")]
transform = Transform3D(0.996134, 0, 0.0878512, 0, 1, 0, -0.0878512, 0, 0.996134, -3, 0, 0)
[node name="platform-medium2" parent="World" instance=ExtResource("7_ixpj3")]
transform = Transform3D(0.995121, 0, 0.0986598, 0, 1, 0, -0.0986598, 0, 0.995121, -5, 0, 4)
[node name="platform-medium4" parent="World" instance=ExtResource("7_ixpj3")]
transform = Transform3D(0.929796, 0, -0.368076, 0, 1, 0, 0.368076, 0, 0.929796, -14.9422, 0.991941, 0.128304)
[node name="platform-medium3" parent="World" instance=ExtResource("7_ixpj3")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, -6)
[node name="platform-falling" parent="World" instance=ExtResource("9_2fnpo")]
transform = Transform3D(0.984808, 0, 0.173648, 0, 1, 0, -0.173648, 0, 0.984808, -9, 0.419294, 4)
[node name="platform-falling2" parent="World" instance=ExtResource("9_2fnpo")]
transform = Transform3D(0.994522, 0, -0.104528, 0, 1, 0, 0.104528, 0, 0.994522, -12, -0.315063, 4)
[node name="platform-falling3" parent="World" instance=ExtResource("9_2fnpo")]
transform = Transform3D(0.939693, 0, 0.34202, 0, 1, 0, -0.34202, 0, 0.939693, -11.7527, 1.8303, -2.30579)
[node name="platform-grass-large-round" parent="World" instance=ExtResource("8_4oh1e")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7, 1, -2)
[node name="flag" parent="World" instance=ExtResource("9_fw1f5")]
transform = Transform3D(0.707107, 0, -0.707107, 0, 1, 0, 0.707107, 0, 0.707107, 0, 3.48077, -6)
[node name="coin" parent="World" instance=ExtResource("10_fwhys")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0.635, 0)
[node name="coin10" parent="World" instance=ExtResource("10_fwhys")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5, 0.635, 4)
[node name="coin2" parent="World" instance=ExtResource("10_fwhys")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.0437, 1.97005, -0.33003)
[node name="coin3" parent="World" instance=ExtResource("10_fwhys")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.0437, 1.97005, -1.33003)
[node name="coin5" parent="World" instance=ExtResource("10_fwhys")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.7731, 2.54941, -2.28223)
[node name="coin6" parent="World" instance=ExtResource("10_fwhys")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -14.8111, 1.6888, 0.328574)
[node name="coin7" parent="World" instance=ExtResource("10_fwhys")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -14.8111, 2.6888, 0.328574)
[node name="coin8" parent="World" instance=ExtResource("10_fwhys")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -14.9647, 0.801836, 3.99354)
[node name="coin9" parent="World" instance=ExtResource("10_fwhys")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5, -6)
[node name="coin4" parent="World" instance=ExtResource("10_fwhys")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.0437, 1.97005, -2.33003)
[node name="cube8" parent="World" instance=ExtResource("13_drtpy")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.5495, 1.10741, -2.666)
[node name="cube9" parent="World" instance=ExtResource("13_drtpy")]
transform = Transform3D(1.27593, -0.401864, 0.422933, 0.471408, 1.30937, -0.178025, -0.343721, 0.304009, 1.32582, 3.33538, 1.37146, -4.1932)
[node name="cube10" parent="World" instance=ExtResource("13_drtpy")]
transform = Transform3D(1.32811, 0.370441, 0.259369, -0.293866, 1.3186, -0.37854, -0.34372, 0.30401, 1.32582, -10.5752, 2.03819, -7.93707)
[node name="cube11" parent="World" instance=ExtResource("13_drtpy")]
transform = Transform3D(0.476646, 0.924607, 0.941422, -0.929853, 0.945559, -0.457882, -0.93624, -0.468385, 0.934042, -11.1815, 2.03819, 9.2812)
[node name="cube12" parent="World" instance=ExtResource("13_drtpy")]
transform = Transform3D(-1.02876, -0.695523, 0.652886, -0.929853, 0.945557, -0.457881, -0.213027, -0.768461, -1.15432, -10.9158, 2.79508, 11.515)
[node name="cube13" parent="World" instance=ExtResource("13_drtpy")]
transform = Transform3D(1.56209, -1.37982, 1.71508, 1.97375, 1.80907, -0.342241, -0.974547, 1.4522, 2.05595, -14.3045, 2.03819, -8.24191)
[node name="cube14" parent="World" instance=ExtResource("13_drtpy")]
transform = Transform3D(1.56209, -1.37982, 1.71508, 1.97375, 1.80907, -0.342241, -0.974547, 1.4522, 2.05595, -15.866, 2.03819, 7.83702)
[node name="Sun" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.422618, -0.694272, 0.582563, 0, 0.642788, 0.766044, -0.906308, 0.323744, -0.271654, 0, 0, 0)
shadow_enabled = true
shadow_opacity = 0.75
[node name="HUD" type="CanvasLayer" parent="."]
script = ExtResource("11_apvpm")
[node name="Icon" type="TextureRect" parent="HUD"]
offset_left = 57.0
offset_top = 67.0
offset_right = 313.0
offset_bottom = 323.0
scale = Vector2(0.2, 0.2)
texture = ExtResource("13_jfda3")
[node name="x" type="Label" parent="HUD"]
offset_left = 112.0
offset_top = 64.0
offset_right = 144.0
offset_bottom = 123.0
text = "×"
label_settings = SubResource("LabelSettings_38ys3")
[node name="Coins" type="Label" parent="HUD"]
offset_left = 144.0
offset_top = 64.0
offset_right = 368.0
offset_bottom = 123.0
text = "0"
label_settings = SubResource("LabelSettings_38ys3")
[connection signal="coin_collected" from="Player" to="HUD" method="_on_coin_collected"]

@ -80,19 +80,20 @@ func handle_effects(delta):
if is_on_floor():
var horizontal_velocity = Vector2(velocity.x, velocity.z)
var speed_factor = horizontal_velocity.length() / movement_speed / delta
if speed_factor > 0.05:
animation.play("walk", 0.5, speed_factor)
animation.play("walk", 0, speed_factor)
if speed_factor > 0.3:
sound_footsteps.stream_paused = false
sound_footsteps.pitch_scale = speed_factor
if speed_factor > 0.75:
particles_trail.emitting = true
else:
animation.play("idle", 0.5)
animation.play("idle", 0)
else:
animation.play("jump", 0.5)
animation.play("jump", 0)
# Handle movement input