feat: first full movement and enemy prototype

This commit is contained in:
Sara 2025-05-25 22:05:08 +02:00
parent d72a037d5a
commit eb8dba058d
42 changed files with 3844 additions and 0 deletions

742
materials/forest.ptex Normal file
View file

@ -0,0 +1,742 @@
{
"connections": [
{
"from": "blend2_2",
"from_port": 0,
"to": "Material",
"to_port": 0
},
{
"from": "graph",
"from_port": 0,
"to": "splatter_color_2",
"to_port": 0
},
{
"from": "splatter_color_2",
"from_port": 0,
"to": "buffer_2",
"to_port": 0
},
{
"from": "buffer_2",
"from_port": 0,
"to": "splatter_color",
"to_port": 0
},
{
"from": "shape_2",
"from_port": 0,
"to": "splatter_color_2",
"to_port": 1
},
{
"from": "scratches",
"from_port": 0,
"to": "colorize",
"to_port": 0
},
{
"from": "colorize",
"from_port": 0,
"to": "blend2_2",
"to_port": 0
},
{
"from": "splatter_color",
"from_port": 0,
"to": "blend2_2",
"to_port": 1
}
],
"label": "Graph",
"longdesc": "",
"name": "416",
"node_position": {
"x": 0,
"y": 0
},
"nodes": [
{
"export_last_target": "Godot/Godot 4 Standard",
"export_paths": {
"Blender": "/home/sara/Documents/gd-projects/going/project/materials/leaves",
"Godot/Godot 4 Standard": "/home/sara/Documents/gd-projects/going/project/materials/forest_background"
},
"name": "Material",
"node_position": {
"x": 367.611938,
"y": 243.147049
},
"parameters": {
"albedo_color": {
"a": 1,
"b": 1,
"g": 1,
"r": 1,
"type": "Color"
},
"ao": 1,
"depth_scale": 0.5,
"emission_energy": 1,
"flags_transparent": true,
"metallic": 0,
"normal": 1,
"roughness": 1,
"size": 11,
"sss": 1
},
"seed_int": 0,
"type": "material"
},
{
"name": "splatter_color",
"node_position": {
"x": -677.745056,
"y": 267.207703
},
"parameters": {
"count": 215,
"opacity": 0,
"rotate": 33.6,
"scale": 0,
"scale_x": 0.5,
"scale_y": 0.5,
"select_inputs": 0,
"variations": false
},
"seed_int": 1176364672,
"type": "splatter_color"
},
{
"connections": [
{
"from": "gradient_2",
"from_port": 0,
"to": "math_3",
"to_port": 0
},
{
"from": "profile",
"from_port": 0,
"to": "transform2",
"to_port": 0
},
{
"from": "transform2",
"from_port": 0,
"to": "mirror_2",
"to_port": 0
},
{
"from": "mirror_2",
"from_port": 0,
"to": "math_5",
"to_port": 0
},
{
"from": "math_5",
"from_port": 0,
"to": "math_4",
"to_port": 0
},
{
"from": "math_6",
"from_port": 0,
"to": "math_4",
"to_port": 1
},
{
"from": "math_4",
"from_port": 0,
"to": "math_7",
"to_port": 1
},
{
"from": "mirror_2",
"from_port": 0,
"to": "math_7",
"to_port": 0
},
{
"from": "gradient",
"from_port": 0,
"to": "math_3",
"to_port": 1
},
{
"from": "mirror",
"from_port": 0,
"to": "math_6",
"to_port": 0
},
{
"from": "math_3",
"from_port": 0,
"to": "mirror",
"to_port": 0
},
{
"from": "fbm2",
"from_port": 0,
"to": "math_8",
"to_port": 1
},
{
"from": "math_7",
"from_port": 0,
"to": "math_8",
"to_port": 0
},
{
"from": "math_8",
"from_port": 0,
"to": "colorize_2",
"to_port": 0
},
{
"from": "colorize_2",
"from_port": 0,
"to": "gen_outputs",
"to_port": 0
},
{
"from": "math_8",
"from_port": 0,
"to": "math",
"to_port": 1
},
{
"from": "math",
"from_port": 0,
"to": "gen_outputs",
"to_port": 1
}
],
"label": "leaf",
"longdesc": "",
"name": "graph",
"node_position": {
"x": -1656.337646,
"y": 239.964798
},
"nodes": [
{
"name": "gradient",
"node_position": {
"x": -1348.702759,
"y": -153.089325
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 0,
"b": 0,
"g": 0,
"pos": 0.453217,
"r": 0
},
{
"a": 1,
"b": 1,
"g": 1,
"pos": 0.51938,
"r": 1
},
{
"a": 0,
"b": 0,
"g": 0,
"pos": 0.61023,
"r": 0
}
],
"type": "Gradient"
},
"repeat": 8,
"rotate": 56.9
},
"seed_int": 0,
"type": "gradient"
},
{
"name": "profile",
"node_position": {
"x": -1083.223633,
"y": -554.144897
},
"parameters": {
"gradient": {
"interpolation": 2,
"points": [
{
"a": 1,
"b": 0.457031,
"g": 0.457031,
"pos": 0,
"r": 0.457031
},
{
"a": 1,
"b": 0.8125,
"g": 0.8125,
"pos": 0.359344,
"r": 0.8125
},
{
"a": 1,
"b": 0.847656,
"g": 0.847656,
"pos": 0.548737,
"r": 0.847656
},
{
"a": 1,
"b": 0.726562,
"g": 0.726562,
"pos": 0.782323,
"r": 0.726562
},
{
"a": 1,
"b": 0.457031,
"g": 0.457031,
"pos": 1,
"r": 0.457031
}
],
"type": "Gradient"
},
"style": 1,
"width": 0.04
},
"seed": 65353,
"seed_locked": true,
"type": "profile"
},
{
"generic_size": 1,
"name": "transform2",
"node_position": {
"x": -840.445862,
"y": -606.117126
},
"parameters": {
"mode": 0,
"rotate": -90,
"scale_x": 1,
"scale_y": 1,
"translate_x": 0,
"translate_y": 0
},
"seed_int": 0,
"type": "transform2"
},
{
"name": "mirror_2",
"node_position": {
"x": -480.723633,
"y": -528.339417
},
"parameters": {
"direction": 0,
"flip_sides": true,
"offset": 0
},
"seed_int": 0,
"type": "mirror"
},
{
"name": "math_5",
"node_position": {
"x": -282.806946,
"y": -478.644958
},
"parameters": {
"clamp": false,
"default_in1": 0,
"default_in2": 0.5,
"op": 2
},
"seed_int": 0,
"type": "math"
},
{
"name": "math_4",
"node_position": {
"x": -16.14028,
"y": -466.144958
},
"parameters": {
"clamp": false,
"default_in1": 0,
"default_in2": 0,
"op": 0
},
"seed_int": 0,
"type": "math"
},
{
"name": "gradient_2",
"node_position": {
"x": -1407.029297,
"y": -349.533844
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 1,
"b": 1,
"g": 1,
"pos": 0.497239,
"r": 1
},
{
"a": 0,
"b": 0,
"g": 0,
"pos": 0.527784,
"r": 0
}
],
"type": "Gradient"
},
"repeat": 1,
"rotate": 0
},
"seed_int": 0,
"type": "gradient"
},
{
"name": "math_3",
"node_position": {
"x": -1096.695801,
"y": -304.339325
},
"parameters": {
"clamp": true,
"default_in1": 0,
"default_in2": 0,
"op": 14
},
"seed_int": 0,
"type": "math"
},
{
"name": "mirror",
"node_position": {
"x": -867.75824,
"y": -317.321564
},
"parameters": {
"direction": 0,
"flip_sides": false,
"offset": 0
},
"seed_int": 0,
"type": "mirror"
},
{
"name": "math_6",
"node_position": {
"x": -279.334747,
"y": -328.644928
},
"parameters": {
"clamp": false,
"default_in1": 0,
"default_in2": 0.4,
"op": 2
},
"seed_int": 0,
"type": "math"
},
{
"name": "math_7",
"node_position": {
"x": 242.193024,
"y": -555.033875
},
"parameters": {
"clamp": false,
"default_in1": 0,
"default_in2": 0,
"op": 2
},
"seed_int": 0,
"type": "math"
},
{
"name": "fbm2",
"node_position": {
"x": 203.57576,
"y": -335.872437
},
"parameters": {
"folds": 0,
"iterations": 5,
"noise": 3,
"offset": 0,
"persistence": 0.3,
"scale_x": 8,
"scale_y": 7
},
"seed_int": 0,
"type": "fbm2"
},
{
"name": "math_8",
"node_position": {
"x": 497.395172,
"y": -566.178772
},
"parameters": {
"clamp": false,
"default_in1": 0,
"default_in2": 0,
"op": 2
},
"seed_int": 0,
"type": "math"
},
{
"name": "colorize_2",
"node_position": {
"x": 768.980774,
"y": -574.599365
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 0,
"b": 1,
"g": 1,
"pos": 0,
"r": 1
},
{
"a": 1,
"b": 1,
"g": 1,
"pos": 0.000001,
"r": 1
},
{
"a": 1,
"b": 0.17453,
"g": 0.519531,
"pos": 0.028095,
"r": 0.201483
},
{
"a": 1,
"b": 0.109985,
"g": 0.207031,
"pos": 0.821499,
"r": 0.163057
}
],
"type": "Gradient"
}
},
"seed_int": 0,
"type": "colorize"
},
{
"name": "gen_inputs",
"node_position": {
"x": -1907.029297,
"y": -436.653137
},
"parameters": {
},
"ports": [
],
"seed_int": 0,
"type": "ios"
},
{
"name": "gen_outputs",
"node_position": {
"x": 1041.897461,
"y": -436.653137
},
"parameters": {
},
"ports": [
{
"name": "color",
"type": "rgba"
},
{
"name": "height",
"type": "f"
}
],
"seed_int": 0,
"type": "ios"
},
{
"name": "gen_parameters",
"node_position": {
"x": -629.842896,
"y": -906.117126
},
"parameters": {
},
"seed_int": 0,
"type": "remote",
"widgets": [
]
},
{
"name": "math",
"node_position": {
"x": 721.161072,
"y": -414.326324
},
"parameters": {
"clamp": true,
"default_in1": 1,
"default_in2": 0,
"op": 1
},
"seed_int": 0,
"type": "math"
}
],
"parameters": {
},
"seed_int": 4286914048,
"shortdesc": "",
"type": "graph"
},
{
"name": "colorize",
"node_position": {
"x": -423.768982,
"y": -8.696673
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 1,
"b": 0,
"g": 0,
"pos": 0,
"r": 0
},
{
"a": 1,
"b": 0.040283,
"g": 0.108828,
"pos": 0.648929,
"r": 0.128906
}
],
"type": "Gradient"
}
},
"seed_int": 0,
"type": "colorize"
},
{
"generic_size": 1,
"name": "blend2_2",
"node_position": {
"x": -232.763931,
"y": 222.17923
},
"parameters": {
"amount1": 1,
"blend_type1": 0
},
"seed_int": 0,
"type": "blend2"
},
{
"name": "splatter_color_2",
"node_position": {
"x": -1449.887329,
"y": 262.733795
},
"parameters": {
"count": 51,
"opacity": 0,
"rotate": 180,
"scale": 0,
"scale_x": 0.05,
"scale_y": 0.05,
"select_inputs": 0,
"variations": false
},
"seed_int": 0,
"type": "splatter_color"
},
{
"name": "buffer_2",
"node_position": {
"x": -1153.669678,
"y": 269.545532
},
"parameters": {
"size": 11
},
"seed_int": 0,
"type": "buffer",
"version": 1
},
{
"name": "shape_2",
"node_position": {
"x": -1695.679688,
"y": 364.80014
},
"parameters": {
"edge": 0.2,
"radius": 0.906667,
"shape": 0,
"sides": 2
},
"seed_int": 0,
"type": "shape"
},
{
"name": "scratches",
"node_position": {
"x": -697.072693,
"y": -39.653183
},
"parameters": {
"angle": 90,
"layers": 12,
"length": 1,
"randomness": 0,
"waviness": 0.51,
"width": 1
},
"seed_int": 1348632320,
"type": "scratches"
}
],
"parameters": {
},
"seed_int": 0,
"shortdesc": "",
"type": "graph"
}

570
materials/grass.ptex Normal file
View file

@ -0,0 +1,570 @@
{
"connections": [
{
"from": "graph",
"from_port": 0,
"to": "colorize",
"to_port": 0
},
{
"from": "decompose",
"from_port": 3,
"to": "Material",
"to_port": 7
},
{
"from": "graph_2",
"from_port": 0,
"to": "colorize_2",
"to_port": 0
},
{
"from": "colorize_2",
"from_port": 0,
"to": "blend2",
"to_port": 1
},
{
"from": "colorize",
"from_port": 0,
"to": "blend2",
"to_port": 0
},
{
"from": "blend2",
"from_port": 0,
"to": "decompose",
"to_port": 0
},
{
"from": "blend2",
"from_port": 0,
"to": "Material",
"to_port": 0
}
],
"label": "Graph",
"longdesc": "",
"name": "@@877",
"node_position": {
"x": 0,
"y": 0
},
"nodes": [
{
"export_last_target": "Blender",
"export_paths": {
"Blender": "/home/sara/Documents/gd-projects/going/project/materials/grass"
},
"name": "Material",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"albedo_color": {
"a": 1,
"b": 1,
"g": 1,
"r": 1,
"type": "Color"
},
"ao": 1,
"depth_scale": 0.5,
"emission_energy": 1,
"flags_transparent": true,
"metallic": 0,
"normal": 1,
"roughness": 1,
"size": 11,
"sss": 1
},
"seed_int": 0,
"type": "material"
},
{
"name": "colorize",
"node_position": {
"x": -846.976868,
"y": -78.05661
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 0,
"b": 0.17299,
"g": 0.441406,
"pos": 0,
"r": 0.162079
},
{
"a": 1,
"b": 0.160828,
"g": 0.265625,
"pos": 1,
"r": 0.188664
}
],
"type": "Gradient"
}
},
"seed_int": 0,
"type": "colorize"
},
{
"connections": [
{
"from": "scratches",
"from_port": 0,
"to": "transform2",
"to_port": 0
},
{
"from": "gradient",
"from_port": 0,
"to": "math",
"to_port": 1
},
{
"from": "transform2",
"from_port": 0,
"to": "math",
"to_port": 0
},
{
"from": "math",
"from_port": 0,
"to": "math_2",
"to_port": 1
},
{
"from": "math_2",
"from_port": 0,
"to": "gen_outputs",
"to_port": 0
}
],
"label": "Grass",
"longdesc": "",
"name": "graph",
"node_position": {
"x": -1096.162842,
"y": -78.621201
},
"nodes": [
{
"name": "scratches",
"node_position": {
"x": -1548.53479,
"y": -136.255402
},
"parameters": {
"angle": 89,
"layers": 194,
"length": 1,
"randomness": 0,
"waviness": 0.47,
"width": 0.55
},
"seed_int": 224188512,
"type": "scratches"
},
{
"generic_size": 1,
"name": "transform2",
"node_position": {
"x": -1223.434204,
"y": -109.301689
},
"parameters": {
"mode": 2,
"rotate": 0,
"scale_x": 0.725,
"scale_y": 2.88,
"translate_x": 0,
"translate_y": 0
},
"seed_int": 0,
"type": "transform2"
},
{
"name": "math",
"node_position": {
"x": -869.267395,
"y": -131.829483
},
"parameters": {
"clamp": false,
"default_in1": 0,
"default_in2": 0,
"op": 2
},
"seed_int": 0,
"type": "math"
},
{
"name": "math_2",
"node_position": {
"x": -642.115601,
"y": -127.834389
},
"parameters": {
"clamp": false,
"default_in1": 1,
"default_in2": 0,
"op": 15
},
"seed_int": 0,
"type": "math"
},
{
"name": "gradient",
"node_position": {
"x": -1197.461914,
"y": 112.114967
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 1,
"b": 0,
"g": 0,
"pos": 0.229181,
"r": 0
},
{
"a": 1,
"b": 1,
"g": 1,
"pos": 1,
"r": 1
}
],
"type": "Gradient"
},
"repeat": 1,
"rotate": 90
},
"seed_int": 0,
"type": "gradient"
},
{
"name": "gen_inputs",
"node_position": {
"x": -2048.534668,
"y": -78.621201
},
"parameters": {
},
"ports": [
],
"seed_int": 0,
"type": "ios"
},
{
"name": "gen_outputs",
"node_position": {
"x": -342.115601,
"y": -78.621201
},
"parameters": {
},
"ports": [
{
"name": "port0",
"type": "f"
}
],
"seed_int": 0,
"type": "ios"
},
{
"name": "gen_parameters",
"node_position": {
"x": -1296.162842,
"y": -436.255402
},
"parameters": {
},
"seed_int": 0,
"type": "remote",
"widgets": [
]
}
],
"parameters": {
},
"seed_int": 0,
"shortdesc": "",
"type": "graph"
},
{
"name": "decompose",
"node_position": {
"x": -274.668549,
"y": 95.007904
},
"parameters": {
},
"seed_int": 0,
"type": "decompose"
},
{
"connections": [
{
"from": "scratches",
"from_port": 0,
"to": "transform2",
"to_port": 0
},
{
"from": "gradient",
"from_port": 0,
"to": "math",
"to_port": 1
},
{
"from": "transform2",
"from_port": 0,
"to": "math",
"to_port": 0
},
{
"from": "math",
"from_port": 0,
"to": "math_2",
"to_port": 1
},
{
"from": "math_2",
"from_port": 0,
"to": "gen_outputs",
"to_port": 0
}
],
"label": "Grass",
"longdesc": "",
"name": "graph_2",
"node_position": {
"x": -1117.733398,
"y": 44.478607
},
"nodes": [
{
"name": "scratches",
"node_position": {
"x": -1548.53479,
"y": -136.255402
},
"parameters": {
"angle": 89,
"layers": 176,
"length": 1,
"randomness": 0,
"waviness": 0.47,
"width": 0.55
},
"seed_int": 224188512,
"type": "scratches"
},
{
"generic_size": 1,
"name": "transform2",
"node_position": {
"x": -1223.434204,
"y": -109.301689
},
"parameters": {
"mode": 2,
"rotate": 0,
"scale_x": 0.725,
"scale_y": 2.88,
"translate_x": 0,
"translate_y": 0
},
"seed_int": 0,
"type": "transform2"
},
{
"name": "math",
"node_position": {
"x": -869.267395,
"y": -131.829483
},
"parameters": {
"clamp": false,
"default_in1": 0,
"default_in2": 0,
"op": 2
},
"seed_int": 0,
"type": "math"
},
{
"name": "math_2",
"node_position": {
"x": -642.115601,
"y": -127.834389
},
"parameters": {
"clamp": false,
"default_in1": 1,
"default_in2": 0,
"op": 15
},
"seed_int": 0,
"type": "math"
},
{
"name": "gradient",
"node_position": {
"x": -1197.461914,
"y": 112.114967
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 1,
"b": 0,
"g": 0,
"pos": 0.582952,
"r": 0
},
{
"a": 1,
"b": 1,
"g": 1,
"pos": 0.91193,
"r": 1
}
],
"type": "Gradient"
},
"repeat": 1,
"rotate": 90
},
"seed_int": 0,
"type": "gradient"
},
{
"name": "gen_inputs",
"node_position": {
"x": -2048.534668,
"y": -78.621201
},
"parameters": {
},
"ports": [
],
"seed_int": 0,
"type": "ios"
},
{
"name": "gen_outputs",
"node_position": {
"x": -342.115601,
"y": -78.621201
},
"parameters": {
},
"ports": [
{
"name": "port0",
"type": "f"
}
],
"seed_int": 0,
"type": "ios"
},
{
"name": "gen_parameters",
"node_position": {
"x": -1296.162842,
"y": -436.255402
},
"parameters": {
},
"seed_int": 0,
"type": "remote",
"widgets": [
]
}
],
"parameters": {
},
"seed_int": 963662848,
"shortdesc": "",
"type": "graph"
},
{
"name": "colorize_2",
"node_position": {
"x": -828.159241,
"y": 52.070419
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 0,
"b": 0.17299,
"g": 0.441406,
"pos": 0,
"r": 0.162079
},
{
"a": 1,
"b": 0.160828,
"g": 0.265625,
"pos": 1,
"r": 0.242701
}
],
"type": "Gradient"
}
},
"seed_int": 0,
"type": "colorize"
},
{
"generic_size": 1,
"name": "blend2",
"node_position": {
"x": -604.662048,
"y": 15.161999
},
"parameters": {
"amount1": 1,
"blend_type1": 0
},
"seed_int": 0,
"type": "blend2"
}
],
"parameters": {
},
"seed_int": 0,
"shortdesc": "",
"type": "graph"
}

111
materials/ground.ptex Normal file
View file

@ -0,0 +1,111 @@
{
"connections": [
{
"from": "fbm2",
"from_port": 0,
"to": "colorize",
"to_port": 0
},
{
"from": "colorize",
"from_port": 0,
"to": "Material",
"to_port": 0
}
],
"label": "Graph",
"longdesc": "",
"name": "@@363",
"node_position": {
"x": 0,
"y": 0
},
"nodes": [
{
"export_last_target": "Godot/Godot 4 Standard",
"export_paths": {
"Godot/Godot 4 Standard": "/home/sara/Documents/gd-projects/going/project/materials/ground"
},
"name": "Material",
"node_position": {
"x": 99.360016,
"y": -18.720001
},
"parameters": {
"albedo_color": {
"a": 1,
"b": 1,
"g": 1,
"r": 1,
"type": "Color"
},
"ao": 1,
"depth_scale": 0.5,
"emission_energy": 1,
"flags_transparent": true,
"metallic": 0,
"normal": 1,
"roughness": 1,
"size": 11,
"sss": 1
},
"seed_int": 0,
"type": "material"
},
{
"name": "fbm2",
"node_position": {
"x": -647.180054,
"y": -99.219971
},
"parameters": {
"folds": 0,
"iterations": 5,
"noise": 9,
"offset": 0,
"persistence": 0.5,
"scale_x": 4,
"scale_y": 4
},
"seed_int": 2451084800,
"type": "fbm2"
},
{
"name": "colorize",
"node_position": {
"x": -295.180054,
"y": -58.219971
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 1,
"b": 0.256348,
"g": 0.342556,
"pos": 0,
"r": 0.375
},
{
"a": 1,
"b": 0.204346,
"g": 0.28125,
"pos": 1,
"r": 0.26623
}
],
"type": "Gradient"
}
},
"seed_int": 0,
"type": "colorize"
}
],
"parameters": {
},
"seed_int": 0,
"shortdesc": "",
"type": "graph"
}

240
materials/hair.ptex Normal file
View file

@ -0,0 +1,240 @@
{
"connections": [
{
"from": "uniform",
"from_port": 0,
"to": "blend2",
"to_port": 0
},
{
"from": "blend2",
"from_port": 0,
"to": "Material",
"to_port": 0
},
{
"from": "scratches_3",
"from_port": 0,
"to": "colorize_2",
"to_port": 0
},
{
"from": "scratches_2",
"from_port": 0,
"to": "colorize",
"to_port": 0
},
{
"from": "colorize_2",
"from_port": 0,
"to": "blend2",
"to_port": 1
},
{
"from": "colorize",
"from_port": 0,
"to": "blend2",
"to_port": 3
},
{
"from": "blend2",
"from_port": 0,
"to": "decompose",
"to_port": 0
},
{
"from": "decompose",
"from_port": 3,
"to": "Material",
"to_port": 7
}
],
"label": "Graph",
"longdesc": "",
"name": "369",
"node_position": {
"x": 0,
"y": 0
},
"nodes": [
{
"export_last_target": "Blender",
"export_paths": {
"Blender": "/home/sara/Documents/gd-projects/going/project/materials/hair"
},
"name": "Material",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"albedo_color": {
"a": 1,
"b": 1,
"g": 1,
"r": 1,
"type": "Color"
},
"ao": 1,
"depth_scale": 0.5,
"emission_energy": 1,
"flags_transparent": true,
"metallic": 0,
"normal": 1,
"roughness": 1,
"size": 11,
"sss": 1
},
"seed_int": 0,
"type": "material"
},
{
"name": "scratches_2",
"node_position": {
"x": -1047.887573,
"y": 222.739914
},
"parameters": {
"angle": -11,
"layers": 85,
"length": 1,
"randomness": 0,
"waviness": 0.16,
"width": 0.32
},
"seed_int": 1752162432,
"type": "scratches"
},
{
"name": "scratches_3",
"node_position": {
"x": -1050.074097,
"y": 25.599455
},
"parameters": {
"angle": -11,
"layers": 85,
"length": 1,
"randomness": 0,
"waviness": 0.54,
"width": 1
},
"seed_int": 1950638336,
"type": "scratches"
},
{
"generic_size": 2,
"name": "blend2",
"node_position": {
"x": -476.871735,
"y": -0.494622
},
"parameters": {
"amount1": 1,
"amount2": 1,
"blend_type1": 0,
"blend_type2": 0
},
"seed_int": 0,
"type": "blend2"
},
{
"name": "colorize",
"node_position": {
"x": -744.927307,
"y": 88.182076
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 0,
"b": 0.436401,
"g": 0.654626,
"pos": 0,
"r": 0.78125
},
{
"a": 1,
"b": 0.293732,
"g": 0.558716,
"pos": 1,
"r": 0.683594
}
],
"type": "Gradient"
}
},
"seed_int": 0,
"type": "colorize"
},
{
"name": "colorize_2",
"node_position": {
"x": -747.446533,
"y": 21.590294
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 0,
"b": 0.361237,
"g": 0.502179,
"pos": 0,
"r": 0.695312
},
{
"a": 1,
"b": 0.238342,
"g": 0.431115,
"pos": 1,
"r": 0.554688
}
],
"type": "Gradient"
}
},
"seed_int": 0,
"type": "colorize"
},
{
"name": "uniform",
"node_position": {
"x": -468.093964,
"y": -64.27243
},
"parameters": {
"color": {
"a": 1,
"b": 0.148543,
"g": 0.40435,
"r": 0.513205,
"type": "Color"
}
},
"seed_int": 0,
"type": "uniform"
},
{
"name": "decompose",
"node_position": {
"x": -203.362564,
"y": 104.463936
},
"parameters": {
},
"seed_int": 0,
"type": "decompose"
}
],
"parameters": {
},
"seed_int": 0,
"shortdesc": "",
"type": "graph"
}

878
materials/leaves.ptex Normal file
View file

@ -0,0 +1,878 @@
{
"connections": [
{
"from": "shape_2",
"from_port": 0,
"to": "transform2_2",
"to_port": 0
},
{
"from": "transform2_2",
"from_port": 0,
"to": "math",
"to_port": 1
},
{
"from": "shape",
"from_port": 0,
"to": "math",
"to_port": 0
},
{
"from": "decompose",
"from_port": 3,
"to": "Material",
"to_port": 7
},
{
"from": "graph",
"from_port": 0,
"to": "splatter_color",
"to_port": 0
},
{
"from": "math",
"from_port": 0,
"to": "splatter_color",
"to_port": 1
},
{
"from": "splatter_color",
"from_port": 0,
"to": "decompose",
"to_port": 0
},
{
"from": "splatter_color",
"from_port": 0,
"to": "Material",
"to_port": 0
},
{
"from": "graph",
"from_port": 1,
"to": "normal_map2",
"to_port": 0
},
{
"from": "math",
"from_port": 0,
"to": "splatter_color_2",
"to_port": 1
},
{
"from": "graph",
"from_port": 0,
"to": "decompose_2",
"to_port": 0
},
{
"from": "normal_map2",
"from_port": 0,
"to": "decompose_3",
"to_port": 0
},
{
"from": "combine",
"from_port": 0,
"to": "splatter_color_2",
"to_port": 0
},
{
"from": "decompose_2",
"from_port": 3,
"to": "combine",
"to_port": 3
},
{
"from": "decompose_3",
"from_port": 0,
"to": "combine",
"to_port": 0
},
{
"from": "decompose_3",
"from_port": 1,
"to": "combine",
"to_port": 1
},
{
"from": "decompose_3",
"from_port": 2,
"to": "combine",
"to_port": 2
},
{
"from": "normal_map2_2",
"from_port": 0,
"to": "blend2",
"to_port": 0
},
{
"from": "splatter_color_2",
"from_port": 0,
"to": "blend2",
"to_port": 1
},
{
"from": "blend2",
"from_port": 0,
"to": "Material",
"to_port": 4
}
],
"label": "Graph",
"longdesc": "",
"name": "416",
"node_position": {
"x": 0,
"y": 0
},
"nodes": [
{
"export_last_target": "Blender",
"export_paths": {
"Blender": "/home/sara/Documents/gd-projects/going/project/materials/leaves"
},
"name": "Material",
"node_position": {
"x": 87.675858,
"y": 228.631851
},
"parameters": {
"albedo_color": {
"a": 1,
"b": 1,
"g": 1,
"r": 1,
"type": "Color"
},
"ao": 1,
"depth_scale": 0.5,
"emission_energy": 1,
"flags_transparent": true,
"metallic": 0,
"normal": 1,
"roughness": 1,
"size": 11,
"sss": 1
},
"seed_int": 0,
"type": "material"
},
{
"name": "shape",
"node_position": {
"x": -1261.26355,
"y": 576.030579
},
"parameters": {
"edge": 0,
"radius": 0.46,
"shape": 1,
"sides": 3
},
"seed_int": 0,
"type": "shape"
},
{
"name": "shape_2",
"node_position": {
"x": -1437.341675,
"y": 716.30072
},
"parameters": {
"edge": 0,
"radius": 0.76,
"shape": 0,
"sides": 2
},
"seed_int": 0,
"type": "shape"
},
{
"generic_size": 1,
"name": "transform2_2",
"node_position": {
"x": -1262.841553,
"y": 716.30072
},
"parameters": {
"mode": 0,
"rotate": 0,
"scale_x": 0.965,
"scale_y": 0.89,
"translate_x": 0,
"translate_y": -0.12
},
"seed_int": 0,
"type": "transform2"
},
{
"name": "math",
"node_position": {
"x": -985.072144,
"y": 549.371643
},
"parameters": {
"clamp": true,
"default_in1": 0,
"default_in2": 0,
"op": 0
},
"seed_int": 0,
"type": "math"
},
{
"name": "decompose",
"node_position": {
"x": -439.931915,
"y": 294.809937
},
"parameters": {
},
"seed_int": 0,
"type": "decompose"
},
{
"name": "splatter_color",
"node_position": {
"x": -712.994995,
"y": 237.37439
},
"parameters": {
"count": 300,
"opacity": 0,
"rotate": 33.6,
"scale": 0,
"scale_x": 0.1,
"scale_y": 0.1,
"select_inputs": 0,
"variations": false
},
"seed_int": 3237170432,
"type": "splatter_color"
},
{
"connections": [
{
"from": "gradient_2",
"from_port": 0,
"to": "math_3",
"to_port": 0
},
{
"from": "profile",
"from_port": 0,
"to": "transform2",
"to_port": 0
},
{
"from": "transform2",
"from_port": 0,
"to": "mirror_2",
"to_port": 0
},
{
"from": "mirror_2",
"from_port": 0,
"to": "math_5",
"to_port": 0
},
{
"from": "math_5",
"from_port": 0,
"to": "math_4",
"to_port": 0
},
{
"from": "math_6",
"from_port": 0,
"to": "math_4",
"to_port": 1
},
{
"from": "math_4",
"from_port": 0,
"to": "math_7",
"to_port": 1
},
{
"from": "mirror_2",
"from_port": 0,
"to": "math_7",
"to_port": 0
},
{
"from": "gradient",
"from_port": 0,
"to": "math_3",
"to_port": 1
},
{
"from": "mirror",
"from_port": 0,
"to": "math_6",
"to_port": 0
},
{
"from": "math_3",
"from_port": 0,
"to": "mirror",
"to_port": 0
},
{
"from": "fbm2",
"from_port": 0,
"to": "math_8",
"to_port": 1
},
{
"from": "math_7",
"from_port": 0,
"to": "math_8",
"to_port": 0
},
{
"from": "math_8",
"from_port": 0,
"to": "colorize_2",
"to_port": 0
},
{
"from": "colorize_2",
"from_port": 0,
"to": "gen_outputs",
"to_port": 0
},
{
"from": "math_8",
"from_port": 0,
"to": "math",
"to_port": 1
},
{
"from": "math",
"from_port": 0,
"to": "gen_outputs",
"to_port": 1
}
],
"label": "leaf",
"longdesc": "",
"name": "graph",
"node_position": {
"x": -1656.337646,
"y": 239.964798
},
"nodes": [
{
"name": "gradient",
"node_position": {
"x": -1348.702759,
"y": -153.089325
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 0,
"b": 0,
"g": 0,
"pos": 0.453217,
"r": 0
},
{
"a": 1,
"b": 1,
"g": 1,
"pos": 0.51938,
"r": 1
},
{
"a": 0,
"b": 0,
"g": 0,
"pos": 0.61023,
"r": 0
}
],
"type": "Gradient"
},
"repeat": 8,
"rotate": 56.9
},
"seed_int": 0,
"type": "gradient"
},
{
"name": "profile",
"node_position": {
"x": -1083.223633,
"y": -554.144897
},
"parameters": {
"gradient": {
"interpolation": 2,
"points": [
{
"a": 1,
"b": 0.457031,
"g": 0.457031,
"pos": 0,
"r": 0.457031
},
{
"a": 1,
"b": 0.8125,
"g": 0.8125,
"pos": 0.359344,
"r": 0.8125
},
{
"a": 1,
"b": 0.847656,
"g": 0.847656,
"pos": 0.548737,
"r": 0.847656
},
{
"a": 1,
"b": 0.726562,
"g": 0.726562,
"pos": 0.782323,
"r": 0.726562
},
{
"a": 1,
"b": 0.457031,
"g": 0.457031,
"pos": 1,
"r": 0.457031
}
],
"type": "Gradient"
},
"style": 1,
"width": 0.04
},
"seed": 65353,
"seed_locked": true,
"type": "profile"
},
{
"generic_size": 1,
"name": "transform2",
"node_position": {
"x": -840.445862,
"y": -606.117126
},
"parameters": {
"mode": 0,
"rotate": -90,
"scale_x": 1,
"scale_y": 1,
"translate_x": 0,
"translate_y": 0
},
"seed_int": 0,
"type": "transform2"
},
{
"name": "mirror_2",
"node_position": {
"x": -480.723633,
"y": -528.339417
},
"parameters": {
"direction": 0,
"flip_sides": true,
"offset": 0
},
"seed_int": 0,
"type": "mirror"
},
{
"name": "math_5",
"node_position": {
"x": -282.806946,
"y": -478.644958
},
"parameters": {
"clamp": false,
"default_in1": 0,
"default_in2": 0.5,
"op": 2
},
"seed_int": 0,
"type": "math"
},
{
"name": "math_4",
"node_position": {
"x": -16.14028,
"y": -466.144958
},
"parameters": {
"clamp": false,
"default_in1": 0,
"default_in2": 0,
"op": 0
},
"seed_int": 0,
"type": "math"
},
{
"name": "gradient_2",
"node_position": {
"x": -1407.029297,
"y": -349.533844
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 1,
"b": 1,
"g": 1,
"pos": 0.497239,
"r": 1
},
{
"a": 0,
"b": 0,
"g": 0,
"pos": 0.527784,
"r": 0
}
],
"type": "Gradient"
},
"repeat": 1,
"rotate": 0
},
"seed_int": 0,
"type": "gradient"
},
{
"name": "math_3",
"node_position": {
"x": -1096.695801,
"y": -304.339325
},
"parameters": {
"clamp": true,
"default_in1": 0,
"default_in2": 0,
"op": 14
},
"seed_int": 0,
"type": "math"
},
{
"name": "mirror",
"node_position": {
"x": -867.75824,
"y": -317.321564
},
"parameters": {
"direction": 0,
"flip_sides": false,
"offset": 0
},
"seed_int": 0,
"type": "mirror"
},
{
"name": "math_6",
"node_position": {
"x": -279.334747,
"y": -328.644928
},
"parameters": {
"clamp": false,
"default_in1": 0,
"default_in2": 0.4,
"op": 2
},
"seed_int": 0,
"type": "math"
},
{
"name": "math_7",
"node_position": {
"x": 242.193024,
"y": -555.033875
},
"parameters": {
"clamp": false,
"default_in1": 0,
"default_in2": 0,
"op": 2
},
"seed_int": 0,
"type": "math"
},
{
"name": "fbm2",
"node_position": {
"x": 203.57576,
"y": -335.872437
},
"parameters": {
"folds": 0,
"iterations": 5,
"noise": 3,
"offset": 0,
"persistence": 0.3,
"scale_x": 8,
"scale_y": 7
},
"seed_int": 0,
"type": "fbm2"
},
{
"name": "math_8",
"node_position": {
"x": 497.395172,
"y": -566.178772
},
"parameters": {
"clamp": false,
"default_in1": 0,
"default_in2": 0,
"op": 2
},
"seed_int": 0,
"type": "math"
},
{
"name": "colorize_2",
"node_position": {
"x": 768.980774,
"y": -574.599365
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 0,
"b": 1,
"g": 1,
"pos": 0,
"r": 1
},
{
"a": 1,
"b": 1,
"g": 1,
"pos": 0.000001,
"r": 1
},
{
"a": 1,
"b": 0.17453,
"g": 0.519531,
"pos": 0.028095,
"r": 0.201483
},
{
"a": 1,
"b": 0.109985,
"g": 0.207031,
"pos": 0.821499,
"r": 0.163057
}
],
"type": "Gradient"
}
},
"seed_int": 0,
"type": "colorize"
},
{
"name": "gen_inputs",
"node_position": {
"x": -1907.029297,
"y": -436.653137
},
"parameters": {
},
"ports": [
],
"seed_int": 0,
"type": "ios"
},
{
"name": "gen_outputs",
"node_position": {
"x": 1041.897461,
"y": -436.653137
},
"parameters": {
},
"ports": [
{
"name": "color",
"type": "rgba"
},
{
"name": "height",
"type": "f"
}
],
"seed_int": 0,
"type": "ios"
},
{
"name": "gen_parameters",
"node_position": {
"x": -629.842896,
"y": -906.117126
},
"parameters": {
},
"seed_int": 0,
"type": "remote",
"widgets": [
]
},
{
"name": "math",
"node_position": {
"x": 721.161072,
"y": -414.326324
},
"parameters": {
"clamp": true,
"default_in1": 1,
"default_in2": 0,
"op": 1
},
"seed_int": 0,
"type": "math"
}
],
"parameters": {
},
"seed_int": 4286914048,
"shortdesc": "",
"type": "graph"
},
{
"name": "normal_map2",
"node_position": {
"x": -1456.827515,
"y": 323.246368
},
"parameters": {
"buffer": 1,
"param2": 3,
"size": 11,
"strength": 1
},
"seed_int": 0,
"type": "normal_map2"
},
{
"name": "splatter_color_2",
"node_position": {
"x": -720.729797,
"y": 539.430908
},
"parameters": {
"count": 300,
"opacity": 0,
"rotate": 33.6,
"scale": 0,
"scale_x": 0.1,
"scale_y": 0.1,
"select_inputs": 0,
"variations": false
},
"seed_int": 3237170432,
"type": "splatter_color"
},
{
"name": "decompose_2",
"node_position": {
"x": -1453.25293,
"y": 465.334259
},
"parameters": {
},
"seed_int": 0,
"type": "decompose"
},
{
"name": "decompose_3",
"node_position": {
"x": -1243.530762,
"y": 316.723114
},
"parameters": {
},
"seed_int": 0,
"type": "decompose"
},
{
"name": "combine",
"node_position": {
"x": -1029.058594,
"y": 316.723114
},
"parameters": {
},
"seed_int": 0,
"type": "combine"
},
{
"generic_size": 1,
"name": "blend2",
"node_position": {
"x": -214.462158,
"y": 494.941772
},
"parameters": {
"amount1": 1,
"blend_type1": 0
},
"seed_int": 0,
"type": "blend2"
},
{
"name": "normal_map2_2",
"node_position": {
"x": -443.462158,
"y": 443.941772
},
"parameters": {
"buffer": 1,
"param2": 0,
"size": 10,
"strength": 1
},
"seed_int": 0,
"type": "normal_map2"
}
],
"parameters": {
},
"seed_int": 0,
"shortdesc": "",
"type": "graph"
}

View file

@ -0,0 +1,182 @@
#include "player_body.h"
#include "core/config/engine.h"
#include "core/input/input.h"
#include "core/math/math_funcs.h"
#include "scene/3d/camera_3d.h"
#include "scene/animation/animation_player.h"
#include "scene/main/viewport.h"
#include "macros.h"
char *const PlayerBody::split_step_action{const_cast<char*>("split_step")};
char *const PlayerBody::move_left_action{const_cast<char*>("move_left")};
char *const PlayerBody::move_right_action{const_cast<char*>("move_right")};
char *const PlayerBody::move_forward_action{const_cast<char*>("move_forward")};
char *const PlayerBody::move_back_action{const_cast<char*>("move_back")};
void PlayerBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_desired_velocity"), &self_type::get_desired_velocity);
ClassDB::bind_method(D_METHOD("get_desired_direction"), &self_type::get_desired_direction);
BIND_PROPERTY(Variant::FLOAT, stopping_deceleration);
BIND_PROPERTY(Variant::FLOAT, start_speed);
BIND_PROPERTY(Variant::FLOAT, step_boost);
BIND_PROPERTY(Variant::FLOAT, min_step_speed);
BIND_PROPERTY(Variant::FLOAT, acceleration);
BIND_PROPERTY(Variant::FLOAT, target_speed);
BIND_PROPERTY(Variant::FLOAT, split_step_time);
BIND_PROPERTY(Variant::FLOAT, split_step_stop_time);
BIND_PROPERTY(Variant::FLOAT, model_lean);
BIND_PROPERTY(Variant::FLOAT, model_lean_speed);
}
void PlayerBody::_notification(int what) {
if(Engine::get_singleton()->is_editor_hint()) {
return;
}
switch(what) {
default:
return;
case NOTIFICATION_ENTER_TREE:
this->enter_tree();
return;
case NOTIFICATION_PROCESS:
this->process(this->get_process_delta_time());
return;
case NOTIFICATION_PHYSICS_PROCESS:
this->physics_process(this->get_physics_process_delta_time());
return;
}
}
void PlayerBody::enter_tree() {
this->set_process(true);
this->set_physics_process(true);
this->model = Object::cast_to<Node3D>(this->get_node(NodePath("character")));
this->anim = Object::cast_to<AnimationPlayer>(this->get_node(NodePath("character/AnimationPlayer")));
this->camera = Object::cast_to<Camera3D>(this->get_node(NodePath("Camera3D")));
this->camera->set_fov(this->min_fov);
}
void PlayerBody::process(double delta) {
Input *input{Input::get_singleton()};
this->movement = Vector2{
input->get_axis(self_type::move_right_action, self_type::move_left_action),
input->get_axis(self_type::move_back_action, self_type::move_forward_action)
}.normalized();
float fov_target{Math::lerp(this->min_fov, this->max_speed_fov, Math::sqrt(this->get_velocity().length() / this->target_speed))};
this->camera->set_fov(Math::move_toward(this->camera->get_fov(), fov_target, float(this->max_delta_fov * delta)));
}
void PlayerBody::physics_process(double delta) {
this->move_and_slide();
}
Vector3 PlayerBody::get_desired_direction() const {
Basis const global{this->camera->get_global_basis()};
Vector3 forward{global.get_column(2)};
Vector3 left{global.get_column(0)};
return Vector3{
Vector3{forward.x, 0.f, forward.z}.normalized() * -this->movement.y +
Vector3{left.x, 0.f, left.z}.normalized() * -this->movement.x
}.normalized();
}
Vector3 PlayerBody::get_desired_velocity() const {
return this->get_desired_direction() * this->target_speed;
}
Vector2 PlayerBody::get_movement_input() const {
return this->movement;
}
AnimationPlayer *PlayerBody::get_anim() const {
return this->anim;
}
Camera3D *PlayerBody::get_camera() const {
return this->camera;
}
Node3D *PlayerBody::get_model() const {
return this->model;
}
void PlayerBody::set_stopping_deceleration(float value) {
this->stopping_deceleration = value;
}
float PlayerBody::get_stopping_deceleration() const {
return this->stopping_deceleration;
}
void PlayerBody::set_start_speed(float value) {
this->start_speed = value;
}
float PlayerBody::get_start_speed() const {
return this->start_speed;
}
void PlayerBody::set_step_boost(float value) {
this->step_boost = value;
}
float PlayerBody::get_step_boost() const {
return this->step_boost;
}
void PlayerBody::set_min_step_speed(float value) {
this->min_step_speed = value;
}
float PlayerBody::get_min_step_speed() const {
return this->min_step_speed;
}
void PlayerBody::set_acceleration(float value) {
this->acceleration = value;
}
float PlayerBody::get_acceleration() const {
return this->acceleration;
}
void PlayerBody::set_target_speed(float value) {
this->target_speed = value;
}
float PlayerBody::get_target_speed() const {
return this->target_speed;
}
void PlayerBody::set_split_step_time(double value) {
this->split_step_time = value;
}
double PlayerBody::get_split_step_time() const {
return this->split_step_time;
}
void PlayerBody::set_split_step_stop_time(double value) {
this->split_step_stop_time = value;
}
double PlayerBody::get_split_step_stop_time() const {
return this->split_step_stop_time;
}
void PlayerBody::set_model_lean(float value) {
this->model_lean = value;
}
float PlayerBody::get_model_lean() const {
return this->model_lean;
}
void PlayerBody::set_model_lean_speed(float value) {
this->model_lean_speed = value;
}
float PlayerBody::get_model_lean_speed() const {
return this->model_lean_speed;
}

View file

@ -0,0 +1,73 @@
#ifndef PLAYER_BODY_H
#define PLAYER_BODY_H
#include "scene/3d/camera_3d.h"
#include "scene/3d/physics/character_body_3d.h"
#include "scene/animation/animation_player.h"
class PlayerBody : public CharacterBody3D {
GDCLASS(PlayerBody, CharacterBody3D);
static void _bind_methods();
void _notification(int what);
void enter_tree();
void process(double delta);
void physics_process(double delta);
public:
Vector3 get_desired_direction() const;
Vector3 get_desired_velocity() const;
Vector2 get_movement_input() const;
AnimationPlayer *get_anim() const;
Camera3D *get_camera() const;
Node3D *get_model() const;
void set_stopping_deceleration(float value);
float get_stopping_deceleration() const;
void set_start_speed(float value);
float get_start_speed() const;
void set_step_boost(float value);
float get_step_boost() const;
void set_min_step_speed(float value);
float get_min_step_speed() const;
void set_acceleration(float value);
float get_acceleration() const;
void set_target_speed(float value);
float get_target_speed() const;
void set_split_step_time(double value);
double get_split_step_time() const;
void set_split_step_stop_time(double value);
double get_split_step_stop_time() const;
void set_model_lean(float value);
float get_model_lean() const;
void set_model_lean_speed(float value);
float get_model_lean_speed() const;
private:
Vector2 movement{0.f, 0.f};
AnimationPlayer *anim{nullptr};
Node3D *model{nullptr};
Camera3D *camera{nullptr};
float stopping_deceleration{20.f};
float start_speed{5.f};
float step_boost{7.f};
float min_step_speed{15.f};
float acceleration{8.f};
float target_speed{30.f};
double split_step_time{0.5};
double split_step_stop_time{0.5};
float max_speed_fov{100.f};
float min_fov{80.f};
double max_delta_fov{100.f};
float model_lean{0.25f};
float model_lean_speed{0.25f};
public:
static char *const split_step_action;
static char *const move_left_action;
static char *const move_right_action;
static char *const move_forward_action;
static char *const move_back_action;
};
#endif // !PLAYER_BODY_H

View file

@ -0,0 +1,174 @@
#include "player_states.h"
#include "core/config/engine.h"
#include "core/math/math_funcs.h"
#include "core/typedefs.h"
#include "going/player_body.h"
PlayerBody *PlayerState::get_body() const {
return this->body;
}
PlayerState::StateID StandingState::get_next_state() const {
if(!this->get_body()->is_on_floor()) {
return FallingState::get_class_static();
} else {
return !this->get_body()->get_movement_input().is_zero_approx()
? RunningState::get_class_static()
: self_type::get_class_static();
}
}
void StandingState::state_entered() {
this->get_body()->get_anim()->play("RESET", 0.1);
}
void StandingState::physics_process(double delta) {
Vector3 const current{this->get_body()->get_velocity()};
float const speed_delta{float(this->get_body()->get_stopping_deceleration() * delta)};
this->get_body()->set_velocity(current.move_toward(Vector3(), speed_delta));
}
PlayerState::StateID RunningState::get_next_state() const {
if(!this->get_body()->is_on_floor()) {
return FallingState::get_class_static();
} else if(this->get_body()->get_velocity().is_zero_approx()) {
return StandingState::get_class_static();
} else if(Input::get_singleton()->is_action_just_pressed(PlayerBody::split_step_action) && this->get_body()->get_velocity().length() > this->get_body()->get_min_step_speed()) {
return SplitStepState::get_class_static();
} else {
return self_type::get_class_static();
}
}
void RunningState::state_entered() {
this->get_body()->get_anim()->play("run", 0.1);
}
void RunningState::process(double delta) {
if(!this->get_body()->get_velocity().is_zero_approx()) {
Vector3 const current{this->get_body()->get_velocity()};
Vector3 const cross{Vector3{0.f, 1.f, 0.f}.cross(current).normalized()};
Vector3 const desired_direction{this->get_body()->get_desired_direction()};
this->lean_modifier = Math::move_toward(
this->lean_modifier,
cross.dot(desired_direction) * this->get_body()->get_model_lean(),
float(this->get_body()->get_model_lean_speed() * delta)
);
Vector3 up{Vector3{0.0, 1.0, 0.0} + cross * this->lean_modifier};
this->get_body()->get_model()->look_at(this->get_body()->get_global_position() - current, up);
}
}
void RunningState::physics_process(double delta) {
Vector3 const current{this->get_body()->get_velocity()};
Vector3 const desired{this->get_body()->get_desired_velocity()};
float const dot{current.dot(desired)};
float const speed_delta{desired.is_zero_approx() || dot < 0.f // if we're stopping or making a full turnaround
? float(this->get_body()->get_stopping_deceleration() * delta) // deceleration
: (current.is_zero_approx() // if we're starting from standstill
? this->get_body()->get_start_speed() // startup boost
: float(this->get_body()->get_acceleration() * delta) // in-motion velocity
)
};
this->get_body()->set_velocity(current.move_toward(desired, speed_delta));
}
void RunningState::state_exited() {
this->get_body()->get_model()->look_at(this->get_body()->get_global_position() - this->get_body()->get_velocity());
this->lean_modifier = 0.f;
}
PlayerState::StateID SplitStepState::get_next_state() const {
if(!this->get_body()->is_on_floor()) {
return FallingState::get_class_static();
} else {
return this->timer <= 0.0
? RunningState::get_class_static()
: self_type::get_class_static();
}
}
void SplitStepState::state_entered() {
this->last_velocity = this->get_body()->get_velocity();
this->timer = this->get_body()->get_split_step_time();
this->get_body()->set_velocity(last_velocity.normalized() * this->get_body()->get_target_speed() * 0.75f);
this->get_body()->get_anim()->play("split-step");
}
void SplitStepState::process(double delta) {
this->timer -= delta;
this->get_body()->set_velocity(this->get_body()->get_velocity()
.move_toward(Vector3(), this->get_body()->get_target_speed() / this->get_body()->get_split_step_stop_time() * delta));
}
void SplitStepState::state_exited() {
if(this->get_body()->is_on_floor()) {
Vector3 const desired_direction{this->get_body()->get_desired_direction()};
float const dot{this->last_velocity.normalized().dot(desired_direction)};
this->get_body()->set_velocity(dot > -0.8f
? desired_direction * MAX(last_velocity.length(), this->get_body()->get_step_boost())
: Vector3()
);
}
}
PlayerState::StateID FallingState::get_next_state() const {
if(this->get_body()->is_on_floor()) {
return RunningState::get_class_static();
} else {
return self_type::get_class_static();
}
}
void FallingState::state_entered() {
this->get_body()->get_anim()->play("falling", 0.1);
}
void FallingState::process(double delta) {
Vector3 const current{this->get_body()->get_velocity()};
Vector3 const flattened{current.x, 0.f, current.z};
this->get_body()->set_velocity((flattened - (flattened * 0.025f)) + Vector3{0.f, current.y - float(9.8 * delta), 0.f});
}
void PlayerStateMachine::_bind_methods() {
}
void PlayerStateMachine::_notification(int what) {
if(Engine::get_singleton()->is_editor_hint()) {
return;
}
switch(what) {
default:
return;
case NOTIFICATION_READY:
this->ready();
break;
case NOTIFICATION_PROCESS:
this->current_state->process(this->get_process_delta_time());
this->try_transition();
break;
case NOTIFICATION_PHYSICS_PROCESS:
this->current_state->physics_process(this->get_physics_process_delta_time());
break;
}
}
void PlayerStateMachine::ready() {
this->set_process(true);
this->set_physics_process(true);
this->body = Object::cast_to<PlayerBody>(this->get_parent());
this->add_state<StandingState>();
this->add_state<RunningState>();
this->add_state<SplitStepState>();
this->add_state<FallingState>();
}
void PlayerStateMachine::try_transition() {
PlayerState::StateID next{this->current_state->get_next_state()};
if(next != this->current_state->get_class()) {
this->current_state->state_exited();
this->current_state = this->states[next];
this->current_state->state_entered();
}
}

View file

@ -0,0 +1,93 @@
#ifndef PLAYER_STATES_H
#define PLAYER_STATES_H
#include "core/object/object.h"
#include "core/templates/hash_map.h"
#include "scene/main/node.h"
class PlayerBody;
class PlayerState : public Object {
GDCLASS(PlayerState, Object);
friend class PlayerStateMachine;
public:
typedef StringName StateID;
public:
virtual StateID get_next_state() const {
return this->get_class();
}
virtual void state_entered() {}
virtual void process(double delta) {}
virtual void physics_process(double delta) {}
virtual void state_exited() {}
PlayerBody *get_body() const;
private:
PlayerBody *body{nullptr};
};
class StandingState : public PlayerState {
GDCLASS(StandingState, PlayerState);
public:
virtual StateID get_next_state() const override;
virtual void state_entered() override;
virtual void physics_process(double delta) override;
};
class RunningState : public PlayerState {
GDCLASS(RunningState, PlayerState);
public:
virtual StateID get_next_state() const override;
virtual void state_entered() override;
virtual void process(double delta) override;
virtual void physics_process(double delta) override;
virtual void state_exited() override;
private:
float lean_modifier{0.f};
};
class SplitStepState : public PlayerState {
GDCLASS(SplitStepState, PlayerState);
public:
virtual StateID get_next_state() const override;
virtual void state_entered() override;
virtual void process(double delta) override;
virtual void state_exited() override;
private:
Vector3 last_velocity{0.f, 0.f, 0.f};
double timer{0.0};
};
class FallingState : public PlayerState {
GDCLASS(FallingState, PlayerState);
public:
virtual StateID get_next_state() const override;
virtual void state_entered() override;
virtual void process(double delta) override;
};
class PlayerStateMachine : public Node {
GDCLASS(PlayerStateMachine, Node);
static void _bind_methods();
void _notification(int what);
void ready();
void try_transition();
template <class TState>
void add_state();
PlayerBody *body{nullptr};
PlayerState *current_state{nullptr};
HashMap<PlayerState::StateID, PlayerState*> states;
};
template <class TState>
void PlayerStateMachine::add_state() {
PlayerState *state{new TState()};
state->body = this->body;
this->states.insert(TState::get_class_static(), state);
if(this->current_state == nullptr) {
this->current_state = state;
state->state_entered();
}
}
#endif // !PLAYER_STATES_H

View file

@ -1,11 +1,19 @@
#include "register_types.h"
#include "core/object/class_db.h"
#include "going/player_body.h"
#include "going/player_states.h"
void initialize_going_module(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
return;
}
ClassDB::register_class<PlayerBody>();
ClassDB::register_class<PlayerState>();
ClassDB::register_class<StandingState>();
ClassDB::register_class<RunningState>();
ClassDB::register_class<SplitStepState>();
ClassDB::register_class<PlayerStateMachine>();
}
void uninitialize_going_module(ModuleInitializationLevel p_level) {

View file

@ -0,0 +1,10 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://djdxb1ptl4fkm"]
[ext_resource type="Texture2D" uid="uid://b2jg52p2jp4m6" path="res://materials/forest_background_albedo.png" id="1"]
[resource]
shading_mode = 0
diffuse_mode = 3
specular_mode = 2
albedo_color = Color(0.262932, 0.262932, 0.262932, 1)
albedo_texture = ExtResource("1")

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 MiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b2jg52p2jp4m6"
path.s3tc="res://.godot/imported/forest_background_albedo.png-642a0f669ff130342dd8093d23e0d358.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://materials/forest_background_albedo.png"
dest_files=["res://.godot/imported/forest_background_albedo.png-642a0f669ff130342dd8093d23e0d358.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cjamwnt4hrwfv"
path.s3tc="res://.godot/imported/grass_albedo.png-57e8badbbc8384a3f2937b01be12939e.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://materials/grass_albedo.png"
dest_files=["res://.godot/imported/grass_albedo.png-57e8badbbc8384a3f2937b01be12939e.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

View file

@ -0,0 +1,8 @@
[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://5knww03rsy1a"]
[ext_resource type="Texture2D" uid="uid://y4ftdhw1dlsv" path="res://materials/ground_albedo.png" id="1"]
[resource]
albedo_texture = ExtResource("1")
uv1_scale = Vector3(0.15, 0.15, 0.15)
uv1_triplanar = true

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://y4ftdhw1dlsv"
path.s3tc="res://.godot/imported/ground_albedo.png-cf078738e4e623441210940e255d1b5d.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://materials/ground_albedo.png"
dest_files=["res://.godot/imported/ground_albedo.png-cf078738e4e623441210940e255d1b5d.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://chn66gpql1jsl"
path.s3tc="res://.godot/imported/hair_albedo.png-981c776a21414d965a3bf5beccbe4944.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://materials/hair_albedo.png"
dest_files=["res://.godot/imported/hair_albedo.png-981c776a21414d965a3bf5beccbe4944.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d1sxmql1f46f6"
path.s3tc="res://.godot/imported/leaves_albedo.png-c7fbf26344a7d1d842a58cae87a5960c.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://materials/leaves_albedo.png"
dest_files=["res://.godot/imported/leaves_albedo.png-c7fbf26344a7d1d842a58cae87a5960c.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ibjmbcpyrog3"
path.s3tc="res://.godot/imported/leaves_normal.png-766133aa6b297b181b025e5d58a9ccb2.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://materials/leaves_normal.png"
dest_files=["res://.godot/imported/leaves_normal.png-766133aa6b297b181b025e5d58a9ccb2.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=1
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=1
roughness/src_normal="res://materials/leaves_normal.png"
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

Binary file not shown.

View file

@ -0,0 +1,53 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://cl7a4q5m73vlw"
path="res://.godot/imported/character.blend-b11623af143592406982b1ed3a0f36d8.scn"
[deps]
source_file="res://models/player/character.blend"
dest_files=["res://.godot/imported/character.blend-b11623af143592406982b1ed3a0f36d8.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={}
blender/nodes/visible=0
blender/nodes/active_collection_only=false
blender/nodes/punctual_lights=true
blender/nodes/cameras=true
blender/nodes/custom_properties=true
blender/nodes/modifiers=1
blender/meshes/colors=false
blender/meshes/uvs=true
blender/meshes/normals=true
blender/meshes/export_geometry_nodes_instances=false
blender/meshes/tangents=true
blender/meshes/skins=2
blender/meshes/export_bones_deforming_mesh_only=false
blender/materials/unpack_enabled=true
blender/materials/export_materials=1
blender/animation/limit_playback=true
blender/animation/always_sample=true
blender/animation/group_tracks=true

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,53 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://dgsd4ysdm0754"
path="res://.godot/imported/tree.blend-8b0773933094aea3a4bad2707cd9b0f0.scn"
[deps]
source_file="res://models/props/tree.blend"
dest_files=["res://.godot/imported/tree.blend-8b0773933094aea3a4bad2707cd9b0f0.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={}
blender/nodes/visible=0
blender/nodes/active_collection_only=false
blender/nodes/punctual_lights=true
blender/nodes/cameras=true
blender/nodes/custom_properties=true
blender/nodes/modifiers=1
blender/meshes/colors=false
blender/meshes/uvs=true
blender/meshes/normals=true
blender/meshes/export_geometry_nodes_instances=false
blender/meshes/tangents=true
blender/meshes/skins=2
blender/meshes/export_bones_deforming_mesh_only=false
blender/materials/unpack_enabled=true
blender/materials/export_materials=1
blender/animation/limit_playback=true
blender/animation/always_sample=true
blender/animation/group_tracks=true

Binary file not shown.

View file

@ -0,0 +1,4 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://dqtsjjn0jp0oj"]
[resource]
albedo_color = Color(0.27451, 0.388235, 0.192157, 1)

Binary file not shown.

View file

@ -0,0 +1,53 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://byylmsg7lopet"
path="res://.godot/imported/test_level.blend-b1faa0e5781efd0945d28d5955d99765.scn"
[deps]
source_file="res://models/terrains/test_level.blend"
dest_files=["res://.godot/imported/test_level.blend-b1faa0e5781efd0945d28d5955d99765.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={}
blender/nodes/visible=0
blender/nodes/active_collection_only=false
blender/nodes/punctual_lights=true
blender/nodes/cameras=true
blender/nodes/custom_properties=true
blender/nodes/modifiers=1
blender/meshes/colors=false
blender/meshes/uvs=true
blender/meshes/normals=true
blender/meshes/export_geometry_nodes_instances=false
blender/meshes/tangents=true
blender/meshes/skins=2
blender/meshes/export_bones_deforming_mesh_only=false
blender/materials/unpack_enabled=true
blender/materials/export_materials=1
blender/animation/limit_playback=true
blender/animation/always_sample=true
blender/animation/group_tracks=true

Binary file not shown.

View file

@ -0,0 +1,45 @@
[gd_scene load_steps=4 format=3 uid="uid://dcgsrdacswacl"]
[ext_resource type="PackedScene" uid="uid://cl7a4q5m73vlw" path="res://models/player/character.blend" id="1_eqqp1"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_bxedw"]
radius = 0.339355
height = 2.15448
[sub_resource type="GDScript" id="GDScript_eqqp1"]
script/source = "extends Camera3D
@export var dist : float = 2.0
@export var pivot_height : float = 3.0
@export var look_target_height : float = 1.0
func _ready():
self.top_level = true
func _process(_delta):
var target : Vector3 = get_parent().global_position + Vector3(0.0, pivot_height, 0.0)
var diff := self.global_position - target
self.look_at_from_position(target + diff.normalized() * dist, get_parent().global_position + Vector3(0.0, look_target_height, 0.0))
"
[node name="Player" type="PlayerBody"]
wall_min_slide_angle = 0.0
floor_max_angle = 0.523599
[node name="PlayerStateMachine" type="PlayerStateMachine" parent="."]
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.05124, 0)
shape = SubResource("CapsuleShape3D_bxedw")
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(-1, -6.18173e-08, -6.18173e-08, -6.71313e-08, 0.99594, 0.0900246, 5.60012e-08, 0.0900246, -0.99594, 3.76484e-07, 1.43409, -2.96511)
fov = 100.0
script = SubResource("GDScript_eqqp1")
dist = 1.5
pivot_height = 2.5
look_target_height = 1.5
[node name="character" parent="." instance=ExtResource("1_eqqp1")]
unique_name_in_owner = true
[editable path="character"]

7
project/objects/tre.tscn Normal file
View file

@ -0,0 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://dqjurq1nq1fle"]
[ext_resource type="PackedScene" uid="uid://dgsd4ysdm0754" path="res://models/props/tree.blend" id="1_n3f34"]
[node name="Node3D" type="Node3D"]
[node name="tree" parent="." instance=ExtResource("1_n3f34")]

View file

@ -0,0 +1,87 @@
[gd_scene load_steps=5 format=3 uid="uid://cdmksnsttot3j"]
[sub_resource type="GDScript" id="GDScript_j6w7d"]
script/source = "extends CharacterBody3D
@export var speed : float = 10.0
@export var target_distance : float = 5.0
@export var detect_distance : float = 100.0
@export var max_home_distance : float = 50.0
@onready var player := $\"../Player\"
@onready var last_velocity : Vector3 = player.velocity
@onready var direction := 1.0 if randi() % 2 == 0 else -1.0
@onready var home := global_position
var homing : bool = true
func _process(_delta : float):
if homing || global_position.distance_squared_to(home) > max_home_distance * max_home_distance:
self.homing = true
self.process_homing()
elif player.global_position.distance_squared_to(global_position) > detect_distance * detect_distance:
self.homing = true
elif player.velocity.normalized().dot(global_position - player.global_position) > -10.0:
self.process_ahead()
else:
self.process_behind()
func process_homing():
if player.global_position.distance_squared_to(global_position) < detect_distance * detect_distance:
self.homing = false
else:
self.velocity = (Vector3(home.x, global_position.y, home.z) - global_position).normalized() * speed
func process_ahead():
var target : Vector3 = player.global_position + last_velocity
target.y = self.global_position.y
var forward : Vector3 = player.velocity.normalized()
if player.global_position.distance_squared_to(self.global_position) < target_distance * target_distance or abs((player.global_position - global_position).dot(forward.cross(Vector3.UP))) < 0.25:
self.velocity = Vector3()
return
if !forward.is_zero_approx():
last_velocity = player.velocity
forward.y = 0.0
forward = forward.normalized()
self.global_basis = Basis(Vector3.UP.cross(forward), Vector3.UP, forward)
self.velocity = (target - self.global_position).normalized() * speed
func process_behind():
var diff : Vector3 = player.global_position - global_position
var forward := diff.normalized()
var left := Vector3.UP.cross(forward)
self.velocity = forward + left * direction * min(10.0, diff.length())
self.look_at(Vector3(player.global_position.x, global_position.y, player.global_position.z))
func _physics_process(_delta : float):
self.velocity += Vector3(0, -0.25, 0)
self.move_and_slide()
"
[sub_resource type="BoxMesh" id="BoxMesh_j6w7d"]
size = Vector3(4.29, 3.77, 2.705)
[sub_resource type="SphereShape3D" id="SphereShape3D_j6w7d"]
radius = 1.83616
[sub_resource type="BoxShape3D" id="BoxShape3D_j6w7d"]
size = Vector3(4.29688, 3.86325, 2.76758)
[node name="WallEnemy" type="CharacterBody3D"]
collision_layer = 2
script = SubResource("GDScript_j6w7d")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.302, 0)
mesh = SubResource("BoxMesh_j6w7d")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.83717, 0)
shape = SubResource("SphereShape3D_j6w7d")
[node name="AnimatableBody3D" type="AnimatableBody3D" parent="."]
collision_layer = 2
collision_mask = 0
sync_to_physics = false
[node name="CollisionShape3D2" type="CollisionShape3D" parent="AnimatableBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.29157, 0)
shape = SubResource("BoxShape3D_j6w7d")

View file

@ -11,5 +11,39 @@ config_version=5
[application]
config/name="going"
run/main_scene="uid://bp0vgy3lnsucd"
config/features=PackedStringArray("4.4", "Forward Plus")
config/icon="res://icon.svg"
[input]
move_left={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
]
}
move_right={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
]
}
move_forward={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
]
}
move_back={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
]
}
split_step={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
]
}
[layer_names]
3d_physics/layer_1="Platforming"
3d_physics/layer_2="Entities"

View file

@ -0,0 +1,209 @@
[gd_scene load_steps=8 format=3 uid="uid://bp0vgy3lnsucd"]
[ext_resource type="PackedScene" uid="uid://dcgsrdacswacl" path="res://objects/player.tscn" id="1_2venv"]
[ext_resource type="Material" uid="uid://5knww03rsy1a" path="res://materials/ground.tres" id="2_paw1w"]
[ext_resource type="PackedScene" uid="uid://dgsd4ysdm0754" path="res://models/props/tree.blend" id="3_j6w7d"]
[ext_resource type="PackedScene" uid="uid://cdmksnsttot3j" path="res://objects/wall_enemy.tscn" id="4_x4b8f"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_j6w7d"]
sky_top_color = Color(0.0825, 0.277292, 0.55, 1)
sky_horizon_color = Color(0.4422, 0.529523, 0.67, 1)
ground_bottom_color = Color(0.132, 0.2, 0.134267, 1)
ground_horizon_color = Color(0.4087, 0.508865, 0.67, 1)
[sub_resource type="Sky" id="Sky_x4b8f"]
sky_material = SubResource("ProceduralSkyMaterial_j6w7d")
[sub_resource type="Environment" id="Environment_tmr53"]
background_mode = 2
sky = SubResource("Sky_x4b8f")
ambient_light_source = 3
[node name="Level" type="Node3D"]
[node name="DirectionalLight3D2" type="DirectionalLight3D" parent="."]
transform = Transform3D(-0.266483, -0.681371, -0.681704, 2.11204e-08, -0.707279, 0.706934, -0.96384, 0.188386, 0.188478, 0, 2.9317, 0)
shadow_enabled = true
directional_shadow_split_1 = 0.0
directional_shadow_blend_splits = true
directional_shadow_fade_start = 0.529
directional_shadow_pancake_size = 0.0
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_tmr53")
[node name="Player" parent="." instance=ExtResource("1_2venv")]
transform = Transform3D(-1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, -2.51976, 0.505302, 31.1225)
collision_layer = 2
collision_mask = 3
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="."]
material_override = ExtResource("2_paw1w")
use_collision = true
collision_mask = 0
[node name="CSGBox3D" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.76738, 0, -46.1384)
size = Vector3(348.365, 1, 313.019)
[node name="CSGBox3D5" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 112.066, 6.68009, -45.6989)
size = Vector3(21.0713, 13.992, 304.707)
[node name="CSGBox3D7" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(0.495368, 0, 0.868683, 0, 1, 0, -0.868683, 0, 0.495368, 14.1738, 6.68009, -130.707)
size = Vector3(21.0713, 13.992, 304.707)
[node name="CSGBox3D8" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(-0.46722, 3.68856e-08, 0.884141, -6.75675e-10, 1, -4.20762e-08, -0.884141, -2.02562e-08, -0.46722, -82.5379, 6.68009, -120.633)
size = Vector3(21.0713, 13.992, 304.707)
[node name="CSGBox3D9" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(-0.995971, 3.58765e-08, -0.0896765, 4.18912e-08, 1, -6.51885e-08, 0.0896765, -6.86825e-08, -0.995971, -135.259, 6.68009, 9.65932)
size = Vector3(21.0713, 13.992, 304.707)
[node name="CSGBox3D10" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(0.0969229, -2.52315e-08, -0.995292, 8.14769e-08, 1, -1.74165e-08, 0.995292, -7.94052e-08, 0.0969229, -16.3844, 6.68009, 83.5363)
size = Vector3(21.0713, 13.992, 304.707)
[node name="CSGBox3D6" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(1, 0, 0, 0, 0.985839, -0.167698, 0, 0.167698, 0.985839, -2.10367, -0.514863, -73.0895)
size = Vector3(21.0713, 9.59839, 48.4176)
[node name="CSGBox3D2" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(0.992826, 0, -0.119565, 0, 1, 0, 0.119565, 0, 0.992826, 36.8326, 7.17883, 25.3075)
size = Vector3(58.4217, 13.992, 35.8203)
[node name="CSGBox3D3" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(0.994166, 0, 0.107861, 0, 1, 0, -0.107861, 0, 0.994166, -26.921, 7.17883, 30.6887)
size = Vector3(33.525, 13.992, 23.5235)
[node name="CSGBox3D4" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(-0.994886, 0, -0.101005, 0, 1, 0, 0.101005, 0, -0.994886, -74.3581, 7.17883, -23.1177)
size = Vector3(21.0713, 13.992, 29.5631)
[node name="CSGBox3D17" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(0.0501054, 0, -0.998744, 0, 1, 0, 0.998744, 0, 0.0501054, -31.5186, 7.17883, -17.6439)
size = Vector3(52.6972, 13.992, 29.5631)
[node name="CSGBox3D18" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(-0.99792, -3.21504e-09, -0.0644627, -3.20072e-09, 1, -3.25401e-10, 0.0644627, -1.18395e-10, -0.99792, -24.4708, 7.17883, 71.5412)
size = Vector3(89.7069, 13.992, 29.5631)
[node name="CSGBox3D11" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(0.0805638, 0, 0.996749, 0, 1, 0, -0.996749, 0, 0.0805638, -52.543, 7.17883, -73.5605)
size = Vector3(33.0723, 13.992, 32.853)
[node name="CSGBox3D12" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(0.0805638, 0, 0.996749, 0, 1, 0, -0.996749, 0, 0.0805638, -82.4276, 7.17883, 22.5865)
size = Vector3(34.7832, 13.992, 47.5163)
[node name="CSGBox3D19" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(0.0137188, 2.19264e-08, -0.999906, 8.12172e-08, 1, 2.30427e-08, 0.999906, -8.15257e-08, 0.0137188, -96.5416, 7.17883, 49.5459)
size = Vector3(27.5021, 13.992, 20.9295)
[node name="CSGBox3D13" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(0.0014831, 3.45693e-09, 0.999998, -1.42038e-10, 1, -3.45673e-09, -0.999998, -1.3691e-10, 0.0014831, 13.6153, 7.17883, -80.6041)
size = Vector3(31.3782, 13.992, 20.3278)
[node name="CSGBox3D20" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(0.498033, -1.86452e-08, 0.867157, 5.66462e-09, 1, 1.82482e-08, -0.867157, -4.17607e-09, 0.498033, 33.162, 7.17883, -72.771)
size = Vector3(31.3782, 13.992, 39.8747)
[node name="CSGBox3D14" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(-0.0663268, 0, 0.997798, 0, 1, 0, -0.997798, 0, -0.0663268, -26.1951, 7.17883, -85.7654)
size = Vector3(48.4302, 13.992, 29.5631)
[node name="CSGBox3D15" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(0.00352485, -1.48914e-08, 0.999994, -2.56226e-09, 1, 1.49005e-08, -0.999994, -2.61477e-09, 0.00352485, -110.126, 7.17883, -80.68)
size = Vector3(64.0211, 13.992, 55.2003)
[node name="CSGBox3D16" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(-0.0429226, 0, 0.999078, 0, 1, 0, -0.999078, 0, -0.0429226, 25.5569, 7.17883, -25.3028)
size = Vector3(34.6213, 13.992, 29.5631)
[node name="CSGBox3D22" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(-0.963275, -1.35554e-08, 0.268516, -1.36363e-08, 1, 1.56402e-09, -0.268516, -2.15497e-09, -0.963275, 67.5984, 7.17883, -15.9523)
size = Vector3(33.4785, 13.992, 30.2278)
[node name="CSGBox3D23" type="CSGBox3D" parent="CSGCombiner3D"]
transform = Transform3D(-0.987724, -8.69745e-09, 0.15621, -8.72721e-09, 1, 4.95334e-10, -0.15621, -8.74023e-10, -0.987724, 89.3285, 7.17883, -64.4714)
size = Vector3(45.022, 13.992, 47.936)
[node name="tree" parent="." instance=ExtResource("3_j6w7d")]
transform = Transform3D(47.1373, 0, 0, 0, 47.1373, 0, 0, 0, 47.1373, -8.21284, -90.0106, -698.149)
[node name="WallEnemy" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 92.6076, 0.500008, -4.21022)
[node name="WallEnemy2" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.82557, 0.500008, -23.3368)
[node name="WallEnemy6" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 69.2337, 0.499985, 6.60841)
[node name="WallEnemy8" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 66.3735, 0.5, -36.0839)
[node name="WallEnemy18" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 47.8969, 0.5, -41.5884)
[node name="WallEnemy9" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -55.6647, 0.500038, 28.0866)
[node name="WallEnemy19" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -35.817, 0.500038, 50.7088)
[node name="WallEnemy20" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -53.4997, 0.5, -22.2078)
[node name="WallEnemy12" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -110.48, 0.594315, 8.49598)
[node name="WallEnemy13" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -101.93, 0.594315, -25.3139)
[node name="WallEnemy14" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -112.681, 0.500122, 55.7373)
[node name="WallEnemy15" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -78.3017, 0.594315, 0.732658)
[node name="WallEnemy16" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 85.9813, 0.594315, 32.7154)
[node name="WallEnemy17" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 58.4806, 0.594315, 55.6496)
[node name="WallEnemy4" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -76.4011, 0.5, 66.5686)
[node name="WallEnemy5" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -41.8591, 0.5, -118.416)
[node name="WallEnemy10" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 19.4218, 0.500015, -104.974)
[node name="WallEnemy11" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -11.8844, 0.499985, -123.468)
[node name="WallEnemy21" parent="." instance=ExtResource("4_x4b8f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -74.085, 0.5, -77.013)
[node name="tree2" parent="." instance=ExtResource("3_j6w7d")]
transform = Transform3D(-0.99367, 0, -0.112336, 0, 1, 0, 0.112336, 0, -0.99367, -87.2561, 0.446493, -28.6384)
[node name="tree3" parent="." instance=ExtResource("3_j6w7d")]
transform = Transform3D(-0.988367, 0, 0.152089, 0, 1, 0, -0.152089, 0, -0.988367, -87.8342, 0.446493, -33.7517)
[node name="tree4" parent="." instance=ExtResource("3_j6w7d")]
transform = Transform3D(-0.776311, 0, 0.630351, 0, 1, 0, -0.630351, 0, -0.776311, -85.8638, 0.446493, -38.0303)
[node name="tree5" parent="." instance=ExtResource("3_j6w7d")]
transform = Transform3D(-0.131564, 0, 0.991308, 0, 1, 0, -0.991308, 0, -0.131564, -81.0296, 0.446493, -38.8804)
[node name="tree6" parent="." instance=ExtResource("3_j6w7d")]
transform = Transform3D(-0.131564, 0, 0.991308, 0, 1, 0, -0.991308, 0, -0.131564, -74.547, 0.446493, -39.3256)
[node name="tree7" parent="." instance=ExtResource("3_j6w7d")]
transform = Transform3D(-0.0441948, 0, 0.999023, 0, 1, 0, -0.999023, 0, -0.0441948, -67.3778, 0.446493, -39.9096)