Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 62a93b257d | |||
| b42d7cddc5 |
@@ -0,0 +1,20 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
|
||||
const SPEED := 100.0
|
||||
const CHASE_RANGE := 8.0
|
||||
|
||||
@export var target : CharacterBody3D
|
||||
@onready var nav_agent: NavigationAgent3D = $nav_agent
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
velocity = Vector3.ZERO
|
||||
|
||||
if global_position.distance_to(target.global_position) < CHASE_RANGE:
|
||||
nav_agent.target_position = target.global_transform.origin
|
||||
var next_nav_point = nav_agent.get_next_path_position()
|
||||
velocity = (next_nav_point - global_transform.origin).normalized() * SPEED * delta
|
||||
look_at(Vector3(target.global_position.x, global_position.y, target.global_position.z), Vector3.UP)
|
||||
|
||||
move_and_slide()
|
||||
@@ -0,0 +1 @@
|
||||
uid://bkr4jcakebo3n
|
||||
@@ -7,11 +7,8 @@ const JUMP_VELOCITY = 10.0
|
||||
|
||||
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
|
||||
@export var view : Node3D
|
||||
@export var timer : Timer
|
||||
var movement_velocity : Vector3
|
||||
var rotation_direction : float
|
||||
var can_jump := true
|
||||
var can_timeout := true
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
handle_input(delta)
|
||||
@@ -19,13 +16,6 @@ func _physics_process(delta: float) -> void:
|
||||
jump()
|
||||
handle_animations()
|
||||
|
||||
if is_on_floor():
|
||||
can_jump = true
|
||||
else:
|
||||
if can_timeout:
|
||||
timer.start()
|
||||
can_timeout = false
|
||||
|
||||
var applied_velocity : Vector3
|
||||
applied_velocity = velocity.lerp(movement_velocity, delta * 10)
|
||||
applied_velocity.y = -gravity
|
||||
@@ -65,14 +55,8 @@ func apply_gravity(delta):
|
||||
gravity += 25 * delta
|
||||
|
||||
func jump():
|
||||
if Input.is_action_just_pressed("move_jump") and can_jump:
|
||||
if Input.is_action_just_pressed("move_jump") and is_on_floor():
|
||||
gravity = -JUMP_VELOCITY
|
||||
can_jump = false
|
||||
|
||||
if gravity > 0 and is_on_floor():
|
||||
gravity = 0
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
can_jump = false
|
||||
can_timeout = true
|
||||
|
||||
+2627
-31
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
||||
[gd_resource type="ShaderMaterial" load_steps=3 format=3 uid="uid://dg5h8p8fu3mhh"]
|
||||
[gd_resource type="ShaderMaterial" format=3 uid="uid://dg5h8p8fu3mhh"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://dmqt66iywru6d" path="res://addons/gdquest_models_shared/shaders/screen_shader.gdshader" id="1_n44cl"]
|
||||
[ext_resource type="Texture2D" uid="uid://bvxkh2pa1nqdq" path="res://addons/gdquest_models_shared/textures/eye_mask.png" id="2_hdljt"]
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,56 @@
|
||||
[gd_scene format=3 uid="uid://bm5hvrj3wgw4n"]
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_ichvf"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_t7hg2"]
|
||||
albedo_color = Color(0.5853036, 0.33189362, 0.12141242, 1)
|
||||
|
||||
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_ichvf"]
|
||||
data = PackedVector3Array(-0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_g2w8g"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_jo043"]
|
||||
albedo_color = Color(0.23899749, 0.47082645, 0.15588555, 1)
|
||||
|
||||
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_t7hg2"]
|
||||
data = PackedVector3Array(-0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_pcong"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_qob4b"]
|
||||
albedo_color = Color(0.2918202, 0.42539257, 0.5005474, 1)
|
||||
|
||||
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_g2w8g"]
|
||||
data = PackedVector3Array(-0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5)
|
||||
|
||||
[node name="MeshLibrary" type="Node3D" unique_id=140917582]
|
||||
|
||||
[node name="ground_block" type="MeshInstance3D" parent="." unique_id=2124879368]
|
||||
mesh = SubResource("BoxMesh_ichvf")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_t7hg2")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="ground_block" unique_id=649599416]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="ground_block/StaticBody3D" unique_id=783986055]
|
||||
shape = SubResource("ConcavePolygonShape3D_ichvf")
|
||||
|
||||
[node name="grass_block" type="MeshInstance3D" parent="." unique_id=1710765515]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.1459441, 0, 0)
|
||||
mesh = SubResource("BoxMesh_g2w8g")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_jo043")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="grass_block" unique_id=1306218989]
|
||||
|
||||
[node name="CollisionShape3D2" type="CollisionShape3D" parent="grass_block/StaticBody3D" unique_id=1490507806]
|
||||
shape = SubResource("ConcavePolygonShape3D_t7hg2")
|
||||
|
||||
[node name="wall_block" type="MeshInstance3D" parent="." unique_id=1042022948]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.2821732, 0, 0)
|
||||
mesh = SubResource("BoxMesh_pcong")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_qob4b")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="wall_block" unique_id=200839924]
|
||||
|
||||
[node name="CollisionShape3D3" type="CollisionShape3D" parent="wall_block/StaticBody3D" unique_id=1022140255]
|
||||
shape = SubResource("ConcavePolygonShape3D_g2w8g")
|
||||
+4
-1
@@ -14,7 +14,8 @@ compatibility/default_parent_skeleton_in_mesh_instance_3d=true
|
||||
|
||||
[application]
|
||||
|
||||
config/name="3D Characters Repository"
|
||||
config/name="Aula_Godot_3D"
|
||||
config/description="Tutorial de como fazer um game plataforma 3D na Godot"
|
||||
run/main_scene="uid://d3jfn55lhv658"
|
||||
config/features=PackedStringArray("4.6", "Forward Plus")
|
||||
config/icon="res://character_icon.png"
|
||||
@@ -100,6 +101,8 @@ move_jump={
|
||||
|
||||
[rendering]
|
||||
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
renderer/rendering_method.mobile="gl_compatibility"
|
||||
lights_and_shadows/directional_shadow/soft_shadow_filter_quality=3
|
||||
lights_and_shadows/positional_shadow/soft_shadow_filter_quality=3
|
||||
anti_aliasing/quality/msaa_3d=2
|
||||
|
||||
Reference in New Issue
Block a user