Add files via upload

master
AiTechEye 2021-10-31 10:36:17 +01:00 committed by GitHub
parent dfc0b9fff8
commit b948199af8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 553 additions and 0 deletions

BIN
Material_001.material Normal file

Binary file not shown.

BIN
Material_003.material Normal file

Binary file not shown.

BIN
Material_004.material Normal file

Binary file not shown.

BIN
Material_005.material Normal file

Binary file not shown.

21
character.gd Normal file
View File

@ -0,0 +1,21 @@
extends KinematicBody
onready var anim = $testman/AnimationPlayer
var cur_anim = ""
func animation(a):
if a != cur_anim:
if a == "stand":
anim.play(a)
if a == "climb":
anim.play(a)
anim.get_animation(a).loop = true
elif a == "walk":
anim.play(a,0.1)
anim.get_animation(a).loop = true
elif a == "run":
anim.play("walk",0.1,2)
anim.get_animation("walk").loop = true
elif a == "jump":
anim.play(a,0.2,1.5)
cur_anim = a

18
character.tscn Normal file
View File

@ -0,0 +1,18 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://character.gd" type="Script" id=1]
[ext_resource path="res://testman.tscn" type="PackedScene" id=2]
[sub_resource type="BoxShape" id=1]
[node name="character" type="KinematicBody"]
script = ExtResource( 1 )
[node name="camera" type="Position3D" parent="."]
transform = Transform( 1, 0, 0, 0, 0.958606, 0.284735, 0, -0.284735, 0.958606, 0, 1.381, 3.22 )
[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 0.4, 0, 0, 0, 1, 0, 0, 0, 0.4, 0, -0.477703, 0 )
shape = SubResource( 1 )
[node name="testman" parent="." instance=ExtResource( 2 )]

7
default_env.tres Normal file
View File

@ -0,0 +1,7 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[resource]
background_mode = 2
background_sky = SubResource( 1 )

39
project.godot Normal file
View File

@ -0,0 +1,39 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
[application]
config/name="Basic action tpv"
run/main_scene="res://scenes/main.tscn"
[global]
hide=false
[input]
ui_accept={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"unicode":0,"echo":false,"script":null)
]
}
jump={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
]
}
[physics]
common/enable_pause_aware_picking=true
[rendering]
environment/default_environment="res://default_env.tres"

211
scenes/main.tscn Normal file
View File

@ -0,0 +1,211 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://scenes/player.tscn" type="PackedScene" id=3]
[sub_resource type="CubeMesh" id=1]
[sub_resource type="SpatialMaterial" id=2]
albedo_color = Color( 0, 0.67451, 0.0705882, 1 )
uv1_scale = Vector3( 30, 10, 10 )
[sub_resource type="BoxShape" id=3]
[node name="main" type="Spatial"]
[node name="player" parent="." instance=ExtResource( 3 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.1238, 0 )
[node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 10, 0, 0, 0, 1, 0, 0, 0, 10, -7.93551, 0, 0 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="StaticBody" type="StaticBody" parent="MeshInstance"]
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance/StaticBody"]
shape = SubResource( 3 )
[node name="MeshInstance2" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.713478, 2.05397, 0 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="StaticBody" type="StaticBody" parent="MeshInstance2"]
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance2/StaticBody"]
shape = SubResource( 3 )
[node name="MeshInstance8" type="MeshInstance" parent="."]
transform = Transform( 0.440349, 0, 0, 0, 2.2152, 0, 0, 0, 4.94169, -10.0459, 3.03512, -4.18925 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="StaticBody" type="StaticBody" parent="MeshInstance8"]
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance8/StaticBody"]
shape = SubResource( 3 )
[node name="MeshInstance3" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.713478, 3.96189, -2.21065 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="StaticBody" type="StaticBody" parent="MeshInstance3"]
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance3/StaticBody"]
shape = SubResource( 3 )
[node name="MeshInstance4" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.713478, 5.82525, -4.38806 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="StaticBody" type="StaticBody" parent="MeshInstance4"]
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance4/StaticBody"]
shape = SubResource( 3 )
[node name="MeshInstance10" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.734278, 5.82525, -9.18736 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="StaticBody" type="StaticBody" parent="MeshInstance10"]
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance10/StaticBody"]
shape = SubResource( 3 )
[node name="MeshInstance11" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1.73668, 1.81503, -7.97215 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="StaticBody" type="StaticBody" parent="MeshInstance11"]
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance11/StaticBody"]
shape = SubResource( 3 )
[node name="MeshInstance15" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 2.68466, 0, 0, 0, 1, -5.49597, 3.55687, 8.09793 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="StaticBody" type="StaticBody" parent="MeshInstance15"]
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance15/StaticBody"]
shape = SubResource( 3 )
[node name="MeshInstance12" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -7.54833, 7.58894, -8.48983 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="StaticBody" type="StaticBody" parent="MeshInstance12"]
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance12/StaticBody"]
shape = SubResource( 3 )
[node name="MeshInstance14" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3.88969, 7.58894, -14.2398 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="StaticBody" type="StaticBody" parent="MeshInstance14"]
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance14/StaticBody"]
shape = SubResource( 3 )
[node name="MeshInstance17" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -12.2264, 7.58894, 8.05409 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="StaticBody" type="StaticBody" parent="MeshInstance17"]
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance17/StaticBody"]
shape = SubResource( 3 )
[node name="MeshInstance18" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -11.493, 14.414, 0.329737 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="StaticBody" type="StaticBody" parent="MeshInstance18"]
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance18/StaticBody"]
shape = SubResource( 3 )
[node name="MeshInstance19" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -6.35312, 18.8925, 0.329737 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="StaticBody" type="StaticBody" parent="MeshInstance19"]
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance19/StaticBody"]
shape = SubResource( 3 )
[node name="MeshInstance13" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 5.15891, 0, 0, 0, 7.9319, -16.7023, 5.80396, -2.09961 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="StaticBody" type="StaticBody" parent="MeshInstance13"]
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance13/StaticBody"]
shape = SubResource( 3 )
[node name="MeshInstance16" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 5.15891, 0, 0, 0, 3.24947, -11.4569, 6.11296, -6.769 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )
__meta__ = {
"_edit_group_": true
}
[node name="StaticBody" type="StaticBody" parent="MeshInstance16"]
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance16/StaticBody"]
shape = SubResource( 3 )

208
scenes/player.gd Normal file
View File

@ -0,0 +1,208 @@
extends Spatial
onready var character = $character
var cam = {
"speed":10,
"current_speed":20,
"mode":2,
}
var action = {
"air_speed":0,
"climb":false,
}
var direction = Vector3()
var direction2 = Vector3()
var velocity = Vector3()
var gravity = -27
var linear_speed = 6
var jump_height = 12
var walk_speed = 8
var run_speed = 16
var speed = 8
var fpv_camera_angle = 0
var fpv_mouse_sensitivity = 0.3
var tpv_camera_speed = 0.001
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
OS.set_window_position(Vector2(0,0))
func rotating(dir):
var a = atan2(dir.x* -1, dir.z* -1)
var rot = character.get_rotation()
if abs(rot.y-a) > PI:
var m = PI * 2
var d = fmod(a-rot.y,m)
a = rot.y + (fmod(2 * d,m)-d)*0.2
else:
a = lerp(rot.y,a,0.1)
character.rotation.y = a
func _input(event):
if Input.is_action_just_pressed("ui_cancel"):
get_tree().quit()
if event is InputEventMouseMotion:
if cam.mode == 1:
# == First player view
rotate_y(deg2rad(-event.relative.x * fpv_mouse_sensitivity))
var change = -event.relative.y * fpv_mouse_sensitivity
if change + fpv_camera_angle < 90 and change + fpv_camera_angle > -90:
$head/Camera.rotate_x(deg2rad(change))
fpv_camera_angle += change
elif cam.mode == 2:
# == Third player view
$head.rotate_y(-event.relative.x * tpv_camera_speed)
$head/tpv.rotate_x(-event.relative.y * tpv_camera_speed)
func _process(delta):
direction = Vector3()
var aim = $head/tpv.get_global_transform().basis
var walk = false
var run = false
if Input.is_key_pressed(KEY_ESCAPE):
get_tree().quit()
if Input.is_key_pressed(KEY_W):
direction -= aim.z
walk = true
if Input.is_key_pressed(KEY_S):
direction += aim.z
walk = true
if Input.is_key_pressed(KEY_A):
direction -= aim.x
walk = true
if Input.is_key_pressed(KEY_D):
direction += aim.x
walk = true
if Input.is_key_pressed(KEY_SHIFT):
run = true
direction = direction.normalized()
if walk and action.climb == false:
direction2 = direction
#===On ground
if character.is_on_floor():
action.air_speed = 0
action.walljump = Vector3()
#Jump
if Input.is_key_pressed(KEY_SPACE) and character.cur_anim != "kong":#Input.is_action_just_pressed("jump"):
velocity.y = jump_height
character.animation("jump")
#Walk
elif walk:
rotating(direction)
if velocity.y < 0.1:
if run:
speed = run_speed
character.animation("run")
if Input.is_key_pressed(KEY_E):
character.cur_anim = "dive"
else:
speed = walk_speed
character.animation("walk")
if cam.current_speed > 2:
cam.current_speed -= delta*5
#idle
else:
character.animation("stand")
if cam.current_speed < cam.speed:
cam.current_speed += delta*10
else:
#camera
if cam.current_speed > 2:
cam.current_speed -= delta*10
#moves===========
#climb
if run == false and action.climb == false and $character/climb1.is_colliding() and velocity.y <= 0 and $character/ground.is_colliding() == false:
var p = $character/climb1.get_collision_point()
$character/climb2.global_transform.origin.y=p.y
$character/climb2.force_update_transform()
$character/climb2.force_raycast_update()
if $character/climb2.is_colliding() and $character/climb1.get_collider() == $character/climb2.get_collider():
character.animation("climb")
speed = walk_speed
action.climb = true
p = $character/climb2.get_collision_point()
var n = $character/climb2.get_collision_normal()*-1
direction = n
direction2 = n
character.global_transform.origin = p + (character.global_transform.origin-$character/armhook.global_transform.origin)
#walljump
elif $character/climb2.is_colliding() and action.climb == false and direction2 != Vector3() and Input.is_key_pressed(KEY_SPACE) and velocity.y < 0 and $character/ground.is_colliding() == false:
var d = todir(direction)
if d != action.walljump:
speed = walk_speed
action.air_speed = 1
direction = direction2 *-20
velocity.y = jump_height
rotating(direction)
character.animation("jump")
action.walljump = d
#jump from climb
elif Input.is_action_just_pressed("jump"):
if action.climb:
speed = walk_speed
action.climb = false
velocity.y = jump_height
character.animation("jump")
direction*=20
rotating(direction2)
#moves===========
#climb
if action.climb:
velocity = Vector3()
if run:
action.climb = false
var n = $character/climb2.get_collision_normal()
var r = Vector2(n.x,n.z).angle()
if Input.is_key_pressed(KEY_A) and $character/armhook/armclimbL.is_colliding():
direction = Vector3(-sin(r),0,cos(r))*3
elif Input.is_key_pressed(KEY_D) and $character/armhook/armclimbR.is_colliding():
direction = Vector3(sin(r),0,-cos(r))*3
else:
return
else:
#move & gravity
velocity.y += gravity * delta
var tv = velocity
if action.air_speed == 0 or action.air_speed == 1:
action.air_speed *=2
tv = velocity.linear_interpolate(direction * speed,6 * delta)
else:
tv = velocity.linear_interpolate(direction * speed,1 * delta)
velocity.x = tv.x
velocity.z = tv.z
velocity = character.move_and_slide(velocity,Vector3(0,1,0))
#camera
$head.transform.origin += (character.transform.origin-$head.transform.origin)/cam.current_speed
if character.transform.origin.y < -50:
character.transform.origin = Vector3(0,0,0)
func todir(a):
if a.x != 0:
a.x = a.x/abs(a.x)
else:
a.x = 0
if a.y != 0:
a.y = a.y/abs(a.y)
else:
a.y = 0
if a.z != 0:
a.z = a.z/abs(a.z)
else:
a.z = 0
return a

41
scenes/player.tscn Normal file
View File

@ -0,0 +1,41 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://scenes/player.gd" type="Script" id=1]
[ext_resource path="res://character.tscn" type="PackedScene" id=2]
[node name="player" type="Spatial"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.50274, 0 )
script = ExtResource( 1 )
[node name="head" type="Spatial" parent="."]
[node name="tpv" type="Camera" parent="head"]
transform = Transform( 1, 0, 0, 0, 0.958606, 0.284735, 0, -0.284735, 0.958606, 0, 1.381, 3.22 )
[node name="character" parent="." instance=ExtResource( 2 )]
[node name="armhook" type="Position3D" parent="character"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.721224, -0.386238 )
[node name="armclimbL" type="RayCast" parent="character/armhook"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1, -0.1, 0.2 )
enabled = true
cast_to = Vector3( 0, 0, -0.4 )
[node name="armclimbR" type="RayCast" parent="character/armhook"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, -0.1, 0.2 )
enabled = true
cast_to = Vector3( 0, 0, -0.4 )
[node name="climb2" type="RayCast" parent="character"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.314461 )
enabled = true
cast_to = Vector3( 0, 0, -1 )
[node name="climb1" type="RayCast" parent="character"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.853106, -0.720601 )
enabled = true
[node name="ground" type="RayCast" parent="character"]
enabled = true
cast_to = Vector3( 0, -2, 0 )

BIN
testman.blend Normal file

Binary file not shown.

BIN
testman.glb Normal file

Binary file not shown.

8
testman.tscn Normal file
View File

@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://testman.glb" type="PackedScene" id=1]
[node name="testman" instance=ExtResource( 1 )]
[node name="Armature001" parent="." index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )