A dungeon delver roguelike using Pathfinder 2nd edition rules
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

I think I fixed the issue where the character would just bounce back and forth, but it causes a pause between rotating and moving, and I don't know how to fix that

+126 -15
+94
CharacterMarker.tscn
··· 1 + [gd_scene load_steps=6 format=3 uid="uid://ckavyyqwj6peh"] 2 + 3 + [sub_resource type="Shader" id="Shader_5ayyv"] 4 + code = "// NOTE: Shader automatically converted from Godot Engine 4.4.1.stable's StandardMaterial3D. 5 + 6 + shader_type spatial; 7 + render_mode blend_mix, depth_draw_opaque, cull_disabled, diffuse_burley, specular_schlick_ggx; 8 + 9 + uniform vec4 albedo : source_color; 10 + uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable; 11 + uniform ivec2 albedo_texture_size; 12 + uniform float point_size : hint_range(0.1, 128.0, 0.1); 13 + 14 + uniform float roughness : hint_range(0.0, 1.0); 15 + uniform sampler2D texture_metallic : hint_default_white, filter_linear_mipmap, repeat_enable; 16 + uniform vec4 metallic_texture_channel; 17 + uniform sampler2D texture_roughness : hint_roughness_r, filter_linear_mipmap, repeat_enable; 18 + 19 + uniform float specular : hint_range(0.0, 1.0, 0.01); 20 + uniform float metallic : hint_range(0.0, 1.0, 0.01); 21 + 22 + uniform sampler2D texture_emission : source_color, hint_default_black, filter_linear_mipmap, repeat_enable; 23 + uniform vec4 emission : source_color; 24 + uniform float emission_energy : hint_range(0.0, 100.0, 0.01); 25 + 26 + uniform vec3 uv1_scale; 27 + uniform vec3 uv1_offset; 28 + uniform vec3 uv2_scale; 29 + uniform vec3 uv2_offset; 30 + 31 + void vertex() { 32 + UV = UV * uv1_scale.xy + uv1_offset.xy; 33 + float x = UV.x; 34 + float y = UV.y; 35 + UV.x = y; 36 + UV.y = x; 37 + } 38 + 39 + void fragment() { 40 + vec2 base_uv = UV; 41 + 42 + vec4 albedo_tex = texture(texture_albedo, base_uv); 43 + ALBEDO = albedo.rgb * albedo_tex.rgb; 44 + 45 + float metallic_tex = dot(texture(texture_metallic, base_uv), metallic_texture_channel); 46 + METALLIC = metallic_tex * metallic; 47 + SPECULAR = specular; 48 + 49 + vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); 50 + float roughness_tex = dot(texture(texture_roughness, base_uv), roughness_texture_channel); 51 + ROUGHNESS = roughness_tex * roughness; 52 + 53 + // Emission: Enabled 54 + vec3 emission_tex = texture(texture_emission, base_uv).rgb; 55 + // Emission Operator: Add 56 + EMISSION = (emission.rgb + emission_tex) * emission_energy; 57 + ALPHA *= albedo.a * albedo_tex.a; 58 + } 59 + " 60 + 61 + [sub_resource type="Gradient" id="Gradient_42hn3"] 62 + colors = PackedColorArray(0, 0, 0, 0, 0, 0, 0, 1) 63 + 64 + [sub_resource type="GradientTexture1D" id="GradientTexture1D_4runf"] 65 + gradient = SubResource("Gradient_42hn3") 66 + 67 + [sub_resource type="ShaderMaterial" id="ShaderMaterial_qul5y"] 68 + render_priority = 0 69 + shader = SubResource("Shader_5ayyv") 70 + shader_parameter/albedo = Color(0, 0, 0, 1) 71 + shader_parameter/texture_albedo = SubResource("GradientTexture1D_4runf") 72 + shader_parameter/albedo_texture_size = Vector2i(256, 1) 73 + shader_parameter/point_size = 1.0 74 + shader_parameter/roughness = 1.0 75 + shader_parameter/metallic_texture_channel = Vector4(1, 0, 0, 0) 76 + shader_parameter/specular = 0.5 77 + shader_parameter/metallic = 0.0 78 + shader_parameter/emission = Color(0, 0, 0, 1) 79 + shader_parameter/emission_energy = 1.0 80 + shader_parameter/uv1_scale = Vector3(1, 1, 1) 81 + shader_parameter/uv1_offset = Vector3(0, 0, 0) 82 + shader_parameter/uv2_scale = Vector3(1, 1, 1) 83 + shader_parameter/uv2_offset = Vector3(0, 0, 0) 84 + 85 + [sub_resource type="CylinderMesh" id="CylinderMesh_qul5y"] 86 + material = SubResource("ShaderMaterial_qul5y") 87 + cap_top = false 88 + cap_bottom = false 89 + 90 + [node name="CharacterMarker" type="Node3D"] 91 + 92 + [node name="MeshInstance3D" type="MeshInstance3D" parent="."] 93 + transform = Transform3D(1, 0, 0, 0, 0.183774, 0, 0, 0, 1, 0, 0.189356, 0) 94 + mesh = SubResource("CylinderMesh_qul5y")
+1 -1
camera/camera.gd
··· 109 109 110 110 if result: 111 111 $"../FighterCharacter".target_position = result.position 112 - $"../FighterCharacter".has_target = true 112 + $"../FighterCharacter".state = $"../FighterCharacter".State.STATE_TARGET 113 113 114 114 $Path3D/PathFollow3D.progress = zoom_percent 115 115
+31 -14
characters/character.gd
··· 3 3 var is_selected: bool = true 4 4 @export var speed: float = 5.0 5 5 var target_position: Vector3 = Vector3.ZERO 6 - var has_target: bool = false 6 + var state: State = State.STATE_IDLE 7 7 var target_rotation: float = 0.0 8 - @export var rotation_speed: float = 0.2 8 + @export var rotation_speed: float = 0.3 9 + var direction: Vector3 = Vector3.ZERO 10 + 11 + enum State {STATE_IDLE, STATE_TARGET, STATE_ROTATE, STATE_MOVE} 9 12 10 13 func _physics_process(delta: float) -> void: 11 - if has_target: 12 - var direction = (target_position - global_transform.origin) 13 - direction.y = 0 14 + if state == State.STATE_IDLE: 15 + pass 16 + elif state == State.STATE_TARGET: 17 + # Has target, calculate direction and check rotation 18 + direction = target_position - global_transform.origin 19 + direction.y = 0.0 20 + direction = direction.normalized() 21 + target_rotation = atan2(direction.x, direction.z) 22 + 23 + if is_equal_approx(global_rotation.y, target_rotation): 24 + state = State.STATE_MOVE 25 + else: 26 + state = State.STATE_ROTATE 27 + elif state == State.STATE_ROTATE: 28 + global_rotate(Vector3.UP, (target_rotation - global_rotation.y) * rotation_speed) 14 29 15 30 if is_equal_approx(global_rotation.y, target_rotation): 16 - if direction.length() < 0.3: 17 - velocity = Vector3.ZERO 18 - target_rotation = global_rotation.y 19 - has_target = false 20 - else: 21 - direction = direction.normalized() 22 - target_rotation = atan2(direction.x, direction.z) 23 - velocity = direction * speed 31 + target_rotation = global_rotation.y 32 + state = State.STATE_MOVE 33 + elif state == State.STATE_MOVE: 34 + direction = target_position - global_transform.origin 35 + direction.y = 0.0 36 + 37 + if direction.length() < 0.1: 38 + velocity = Vector3.ZERO 39 + state = State.STATE_IDLE 24 40 else: 25 - global_rotate(Vector3.UP, (target_rotation - global_rotation.y) * rotation_speed) 41 + var norm_dir = direction.normalized() 42 + velocity = direction * speed 26 43 27 44 move_and_slide()