first commit
This commit is contained in:
commit
fb5877b192
|
@ -0,0 +1,3 @@
|
||||||
|
source_md5="47313fa4c47a9963fddd764e1ec6e4a8"
|
||||||
|
dest_md5="2ded9e7f9060e2b530aab678b135fc5b"
|
||||||
|
|
Binary file not shown.
|
@ -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 )
|
|
@ -0,0 +1,41 @@
|
||||||
|
[preset.0]
|
||||||
|
|
||||||
|
name="A Vengeful Mark"
|
||||||
|
platform="Windows Desktop"
|
||||||
|
runnable=true
|
||||||
|
custom_features=""
|
||||||
|
export_filter="all_resources"
|
||||||
|
include_filter=""
|
||||||
|
exclude_filter=""
|
||||||
|
export_path="../export/A Vengeful Mark.exe"
|
||||||
|
script_export_mode=1
|
||||||
|
script_encryption_key=""
|
||||||
|
|
||||||
|
[preset.0.options]
|
||||||
|
|
||||||
|
custom_template/debug=""
|
||||||
|
custom_template/release=""
|
||||||
|
binary_format/64_bits=true
|
||||||
|
binary_format/embed_pck=false
|
||||||
|
texture_format/bptc=false
|
||||||
|
texture_format/s3tc=true
|
||||||
|
texture_format/etc=false
|
||||||
|
texture_format/etc2=false
|
||||||
|
texture_format/no_bptc_fallbacks=true
|
||||||
|
codesign/enable=false
|
||||||
|
codesign/identity_type=0
|
||||||
|
codesign/identity=""
|
||||||
|
codesign/password=""
|
||||||
|
codesign/timestamp=true
|
||||||
|
codesign/timestamp_server_url=""
|
||||||
|
codesign/digest_algorithm=1
|
||||||
|
codesign/description=""
|
||||||
|
codesign/custom_options=PoolStringArray( )
|
||||||
|
application/icon=""
|
||||||
|
application/file_version=""
|
||||||
|
application/product_version=""
|
||||||
|
application/company_name=""
|
||||||
|
application/product_name=""
|
||||||
|
application/file_description=""
|
||||||
|
application/copyright=""
|
||||||
|
application/trademarks=""
|
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://icon.png"
|
||||||
|
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=true
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
|
@ -0,0 +1,9 @@
|
||||||
|
extends Spatial
|
||||||
|
|
||||||
|
onready var monster = $Navigation/Monster
|
||||||
|
onready var player = $Navigation/Character
|
||||||
|
onready var nav = $Navigation
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
monster.set_nav(nav)
|
||||||
|
monster.set_target(player)
|
|
@ -0,0 +1,47 @@
|
||||||
|
[gd_scene load_steps=8 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://maze_unofficial/tiles.meshlib" type="MeshLibrary" id=1]
|
||||||
|
[ext_resource path="res://system/character/character.tscn" type="PackedScene" id=2]
|
||||||
|
[ext_resource path="res://maze_unofficial/Level.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://maze_unofficial/Monster.tscn" type="PackedScene" id=4]
|
||||||
|
|
||||||
|
[sub_resource type="CubeMesh" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=2]
|
||||||
|
flags_transparent = true
|
||||||
|
albedo_color = Color( 1, 1, 1, 0 )
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape" id=3]
|
||||||
|
|
||||||
|
[node name="Level" type="Spatial"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.01558, 0 )
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
|
[node name="Navigation" type="Navigation" parent="."]
|
||||||
|
|
||||||
|
[node name="NavigationMeshInstance" type="NavigationMeshInstance" parent="Navigation"]
|
||||||
|
|
||||||
|
[node name="Floor" type="GridMap" parent="Navigation/NavigationMeshInstance"]
|
||||||
|
mesh_library = ExtResource( 1 )
|
||||||
|
data = {
|
||||||
|
"cells": PoolIntArray( 0, 0, 2, 1, 0, 2, 2, 0, 2, 3, 0, 2, 4, 0, 1, 5, 0, 1, 6, 0, 1, 7, 0, 2, 8, 0, 2, 9, 0, 2, 10, 0, 1, 11, 0, 2, 12, 0, 2, 13, 0, 1, 65532, 0, 1, 65533, 0, 2, 65534, 0, 1, 65535, 0, 2, 0, 1, 2, 1, 1, 2, 2, 1, 2, 3, 1, 2, 4, 1, 2, 5, 1, 2, 6, 1, 2, 7, 1, 2, 8, 1, 2, 9, 1, 2, 10, 1, 2, 11, 1, 2, 12, 1, 2, 13, 1, 1, 65532, 1, 1, 65533, 1, 2, 65534, 1, 2, 65535, 1, 2, 0, 2, 1, 1, 2, 1, 2, 2, 1, 3, 2, 1, 4, 2, 1, 5, 2, 1, 6, 2, 1, 7, 2, 1, 8, 2, 1, 9, 2, 1, 10, 2, 1, 11, 2, 1, 12, 2, 1, 13, 2, 1, 65532, 2, 1, 65533, 2, 1, 65534, 2, 1, 65535, 2, 1, 0, 65523, 1, 1, 65523, 1, 2, 65523, 1, 3, 65523, 1, 4, 65523, 1, 5, 65523, 1, 6, 65523, 1, 7, 65523, 1, 8, 65523, 1, 9, 65523, 1, 10, 65523, 1, 11, 65523, 1, 12, 65523, 1, 13, 65523, 1, 65532, 65523, 1, 65533, 65523, 1, 65534, 65523, 1, 65535, 65523, 1, 0, 65524, 2, 1, 65524, 2, 2, 65524, 2, 3, 65524, 2, 4, 65524, 2, 5, 65524, 2, 6, 65524, 2, 7, 65524, 2, 8, 65524, 2, 9, 65524, 2, 10, 65524, 2, 11, 65524, 2, 12, 65524, 2, 13, 65524, 1, 65532, 65524, 1, 65533, 65524, 2, 65534, 65524, 2, 65535, 65524, 2, 0, 65525, 1, 1, 65525, 1, 2, 65525, 2, 3, 65525, 1, 4, 65525, 2, 5, 65525, 1, 6, 65525, 1, 7, 65525, 1, 8, 65525, 1, 9, 65525, 1, 10, 65525, 2, 11, 65525, 2, 12, 65525, 2, 13, 65525, 1, 65532, 65525, 1, 65533, 65525, 2, 65534, 65525, 1, 65535, 65525, 1, 0, 65526, 2, 1, 65526, 2, 2, 65526, 2, 3, 65526, 2, 4, 65526, 2, 5, 65526, 2, 6, 65526, 2, 7, 65526, 2, 8, 65526, 2, 9, 65526, 2, 10, 65526, 2, 11, 65526, 2, 12, 65526, 2, 13, 65526, 1, 65532, 65526, 1, 65533, 65526, 2, 65534, 65526, 2, 65535, 65526, 2, 0, 65527, 2, 1, 65527, 2, 2, 65527, 2, 3, 65527, 1, 4, 65527, 2, 5, 65527, 1, 6, 65527, 2, 7, 65527, 1, 8, 65527, 2, 9, 65527, 1, 10, 65527, 1, 11, 65527, 1, 12, 65527, 2, 13, 65527, 1, 65532, 65527, 1, 65533, 65527, 2, 65534, 65527, 1, 65535, 65527, 2, 0, 65528, 1, 1, 65528, 1, 2, 65528, 1, 3, 65528, 2, 4, 65528, 2, 5, 65528, 1, 6, 65528, 2, 7, 65528, 1, 8, 65528, 2, 9, 65528, 2, 10, 65528, 2, 11, 65528, 2, 12, 65528, 2, 13, 65528, 1, 65532, 65528, 1, 65533, 65528, 2, 65534, 65528, 2, 65535, 65528, 1, 0, 65529, 2, 1, 65529, 2, 2, 65529, 2, 3, 65529, 2, 4, 65529, 2, 5, 65529, 1, 6, 65529, 2, 7, 65529, 1, 8, 65529, 2, 9, 65529, 1, 10, 65529, 1, 11, 65529, 1, 12, 65529, 2, 13, 65529, 1, 65532, 65529, 1, 65533, 65529, 2, 65534, 65529, 2, 65535, 65529, 2, 0, 65530, 2, 1, 65530, 2, 2, 65530, 2, 3, 65530, 2, 4, 65530, 2, 5, 65530, 1, 6, 65530, 2, 7, 65530, 1, 8, 65530, 2, 9, 65530, 2, 10, 65530, 2, 11, 65530, 2, 12, 65530, 2, 13, 65530, 1, 65532, 65530, 1, 65533, 65530, 2, 65534, 65530, 2, 65535, 65530, 1, 0, 65531, 2, 1, 65531, 1, 2, 65531, 1, 3, 65531, 1, 4, 65531, 2, 5, 65531, 2, 6, 65531, 2, 7, 65531, 2, 8, 65531, 2, 9, 65531, 2, 10, 65531, 2, 11, 65531, 1, 12, 65531, 2, 13, 65531, 1, 65532, 65531, 1, 65533, 65531, 2, 65534, 65531, 2, 65535, 65531, 1, 0, 65532, 2, 1, 65532, 2, 2, 65532, 2, 3, 65532, 2, 4, 65532, 2, 5, 65532, 2, 6, 65532, 2, 7, 65532, 2, 8, 65532, 2, 9, 65532, 2, 10, 65532, 2, 11, 65532, 2, 12, 65532, 2, 13, 65532, 1, 65532, 65532, 1, 65533, 65532, 2, 65534, 65532, 2, 65535, 65532, 1, 0, 65533, 2, 1, 65533, 2, 2, 65533, 1, 3, 65533, 2, 4, 65533, 1, 5, 65533, 1, 6, 65533, 1, 7, 65533, 2, 8, 65533, 2, 9, 65533, 2, 10, 65533, 1, 11, 65533, 2, 12, 65533, 2, 13, 65533, 1, 65532, 65533, 1, 65533, 65533, 2, 65534, 65533, 2, 65535, 65533, 2, 0, 65534, 1, 1, 65534, 2, 2, 65534, 1, 3, 65534, 2, 4, 65534, 2, 5, 65534, 2, 6, 65534, 2, 7, 65534, 2, 8, 65534, 2, 9, 65534, 1, 10, 65534, 2, 11, 65534, 2, 12, 65534, 2, 13, 65534, 1, 65532, 65534, 1, 65533, 65534, 2, 65534, 65534, 1, 65535, 65534, 1, 0, 65535, 2, 1, 65535, 2, 2, 65535, 1, 3, 65535, 2, 4, 65535, 2, 5, 65535, 2, 6, 65535, 2, 7, 65535, 2, 8, 65535, 1, 9, 65535, 2, 10, 65535, 2, 11, 65535, 1, 12, 65535, 2, 13, 65535, 1, 65532, 65535, 1, 65533, 65535, 2, 65534, 65535, 2, 65535, 65535, 2 )
|
||||||
|
}
|
||||||
|
__meta__ = {
|
||||||
|
"_editor_clip_": 0
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Character" parent="Navigation" instance=ExtResource( 2 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1.73979, 2.41006, 0 )
|
||||||
|
|
||||||
|
[node name="Monster" parent="Navigation" instance=ExtResource( 4 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 22.103, 1.22928, -21.007 )
|
||||||
|
|
||||||
|
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||||
|
transform = Transform( 30, 0, 0, 0, 1, 0, 0, 0, 30, 15, 0, 0 )
|
||||||
|
mesh = SubResource( 1 )
|
||||||
|
material/0 = SubResource( 2 )
|
||||||
|
|
||||||
|
[node name="StaticBody" type="StaticBody" parent="MeshInstance"]
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance/StaticBody"]
|
||||||
|
shape = SubResource( 3 )
|
|
@ -0,0 +1,48 @@
|
||||||
|
extends KinematicBody
|
||||||
|
|
||||||
|
const SPEED = 2.0
|
||||||
|
|
||||||
|
var target = null
|
||||||
|
var nav : Navigation = null
|
||||||
|
var vel = Vector3()
|
||||||
|
|
||||||
|
onready var hitbox = $HitboxArea
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
hitbox.connect("body_entered", self, "on_hit_player")
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
if target == null:
|
||||||
|
return
|
||||||
|
|
||||||
|
var path = get_path_to(target.global_transform.origin)
|
||||||
|
|
||||||
|
if path.size() > 0:
|
||||||
|
move_along_path(path)
|
||||||
|
|
||||||
|
func get_path_to(target):
|
||||||
|
return nav.get_simple_path(global_transform.origin, target)
|
||||||
|
|
||||||
|
func move_along_path(path):
|
||||||
|
if path.size() <= 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
path.remove(0)
|
||||||
|
|
||||||
|
var target = path[0]
|
||||||
|
|
||||||
|
if global_transform.origin.distance_to(target) < 0.1:
|
||||||
|
path.remove(0)
|
||||||
|
|
||||||
|
vel = (target - translation).normalized() * SPEED
|
||||||
|
|
||||||
|
vel = move_and_slide(vel)
|
||||||
|
|
||||||
|
func set_target(target):
|
||||||
|
self.target = target
|
||||||
|
|
||||||
|
func set_nav(nav):
|
||||||
|
self.nav = nav
|
||||||
|
|
||||||
|
func on_hit_player(body):
|
||||||
|
print(body.name, " got catch by the Monster!")
|
|
@ -0,0 +1,33 @@
|
||||||
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://maze_unofficial/Monster.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape" id=1]
|
||||||
|
radius = 0.65
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleMesh" id=2]
|
||||||
|
radius = 0.65
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape" id=3]
|
||||||
|
extents = Vector3( 0.7138, 1.17588, 1 )
|
||||||
|
|
||||||
|
[node name="Monster" type="KinematicBody"]
|
||||||
|
collision_layer = 8
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 1.02075, 0 )
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 1.02075, 0 )
|
||||||
|
mesh = SubResource( 2 )
|
||||||
|
material/0 = null
|
||||||
|
|
||||||
|
[node name="HitboxArea" type="Area" parent="."]
|
||||||
|
collision_layer = 8
|
||||||
|
collision_mask = 4
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="HitboxArea"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 )
|
||||||
|
shape = SubResource( 3 )
|
Binary file not shown.
|
@ -0,0 +1,39 @@
|
||||||
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
|
[sub_resource type="PlaneMesh" id=7]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=14]
|
||||||
|
albedo_color = Color( 0.486275, 0.486275, 0.486275, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="NavigationMesh" id=8]
|
||||||
|
vertices = PoolVector3Array( 1, 0, 1, -1, 0, 1, 1, 0, -1, -1, 0, -1 )
|
||||||
|
polygons = [ PoolIntArray( 0, 1, 2 ), PoolIntArray( 1, 3, 2 ) ]
|
||||||
|
|
||||||
|
[sub_resource type="CubeMesh" id=4]
|
||||||
|
size = Vector3( 2, 6, 2 )
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=5]
|
||||||
|
albedo_color = Color( 0.180392, 0.180392, 0.180392, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape" id=6]
|
||||||
|
extents = Vector3( 1, 3, 1 )
|
||||||
|
|
||||||
|
[node name="tiles" type="Node"]
|
||||||
|
|
||||||
|
[node name="floor" type="MeshInstance" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -2.37159, 0, 0 )
|
||||||
|
mesh = SubResource( 7 )
|
||||||
|
material/0 = SubResource( 14 )
|
||||||
|
|
||||||
|
[node name="NavigationMeshInstance" type="NavigationMeshInstance" parent="floor"]
|
||||||
|
navmesh = SubResource( 8 )
|
||||||
|
|
||||||
|
[node name="Wall" type="MeshInstance" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 )
|
||||||
|
mesh = SubResource( 4 )
|
||||||
|
material/0 = SubResource( 5 )
|
||||||
|
|
||||||
|
[node name="StaticBody" type="StaticBody" parent="Wall"]
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="Wall/StaticBody"]
|
||||||
|
shape = SubResource( 6 )
|
|
@ -0,0 +1,60 @@
|
||||||
|
; 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="A Vengeful Mark"
|
||||||
|
run/main_scene="res://test.tscn"
|
||||||
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
move_forward={
|
||||||
|
"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":87,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_backward={
|
||||||
|
"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":83,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_right={
|
||||||
|
"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":68,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_left={
|
||||||
|
"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":65,"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)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
[layer_names]
|
||||||
|
|
||||||
|
3d_physics/layer_1="Grid"
|
||||||
|
3d_physics/layer_3="Player"
|
||||||
|
3d_physics/layer_4="Monster"
|
||||||
|
|
||||||
|
[physics]
|
||||||
|
|
||||||
|
common/enable_pause_aware_picking=true
|
||||||
|
|
||||||
|
[rendering]
|
||||||
|
|
||||||
|
quality/driver/driver_name="GLES2"
|
||||||
|
vram_compression/import_etc=true
|
||||||
|
vram_compression/import_etc2=false
|
||||||
|
environment/default_environment="res://default_env.tres"
|
|
@ -0,0 +1,73 @@
|
||||||
|
extends KinematicBody
|
||||||
|
|
||||||
|
var speed = 7
|
||||||
|
const ACCEL_DEFAULT = 2
|
||||||
|
const ACCEL_AIR = 1
|
||||||
|
onready var accel = ACCEL_DEFAULT
|
||||||
|
var gravity = 9.8
|
||||||
|
var jump = 3
|
||||||
|
|
||||||
|
var cam_accel = 40
|
||||||
|
var mouse_sense = 0.1
|
||||||
|
var snap
|
||||||
|
|
||||||
|
var direction = Vector3()
|
||||||
|
var velocity = Vector3()
|
||||||
|
var gravity_vec = Vector3()
|
||||||
|
var movement = Vector3()
|
||||||
|
|
||||||
|
onready var head = $Head
|
||||||
|
onready var camera = $Head/Camera
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
#hides the cursor
|
||||||
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
|
|
||||||
|
func _input(event):
|
||||||
|
#get mouse input for camera rotation
|
||||||
|
if event is InputEventMouseMotion:
|
||||||
|
rotate_y(deg2rad(-event.relative.x * mouse_sense))
|
||||||
|
head.rotate_x(deg2rad(-event.relative.y * mouse_sense))
|
||||||
|
head.rotation.x = clamp(head.rotation.x, deg2rad(-89), deg2rad(89))
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
#camera physics interpolation to reduce physics jitter on high refresh-rate monitors
|
||||||
|
if Engine.get_frames_per_second() > Engine.iterations_per_second:
|
||||||
|
camera.set_as_toplevel(true)
|
||||||
|
camera.global_transform.origin = camera.global_transform.origin.linear_interpolate(head.global_transform.origin, cam_accel * delta)
|
||||||
|
camera.rotation.y = rotation.y
|
||||||
|
camera.rotation.x = head.rotation.x
|
||||||
|
else:
|
||||||
|
camera.set_as_toplevel(false)
|
||||||
|
camera.global_transform = head.global_transform
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
#get keyboard input
|
||||||
|
direction = Vector3.ZERO
|
||||||
|
var h_rot = global_transform.basis.get_euler().y
|
||||||
|
var f_input = Input.get_action_strength("move_backward") - Input.get_action_strength("move_forward")
|
||||||
|
var h_input = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
|
||||||
|
direction = Vector3(h_input, 0, f_input).rotated(Vector3.UP, h_rot).normalized()
|
||||||
|
|
||||||
|
#jumping and gravity
|
||||||
|
if is_on_floor():
|
||||||
|
snap = -get_floor_normal()
|
||||||
|
accel = ACCEL_DEFAULT
|
||||||
|
gravity_vec = Vector3.ZERO
|
||||||
|
else:
|
||||||
|
snap = Vector3.DOWN
|
||||||
|
accel = ACCEL_AIR
|
||||||
|
gravity_vec += Vector3.DOWN * gravity * delta
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("jump") and is_on_floor():
|
||||||
|
snap = Vector3.ZERO
|
||||||
|
gravity_vec = Vector3.UP * jump
|
||||||
|
|
||||||
|
#make it move
|
||||||
|
velocity = velocity.linear_interpolate(direction * speed, accel * delta)
|
||||||
|
movement = velocity + gravity_vec
|
||||||
|
|
||||||
|
move_and_slide_with_snap(movement, snap, Vector3.UP)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://system/character/character.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape" id=1]
|
||||||
|
radius = 0.5
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleMesh" id=2]
|
||||||
|
radius = 0.5
|
||||||
|
|
||||||
|
[node name="Character" type="KinematicBody"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1.5, 0, 0, 0, 1, 0, 0, 0 )
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 9
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0 )
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0 )
|
||||||
|
mesh = SubResource( 2 )
|
||||||
|
material/0 = null
|
||||||
|
|
||||||
|
[node name="Head" type="Spatial" parent="."]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0 )
|
||||||
|
|
||||||
|
[node name="Camera" type="Camera" parent="Head"]
|
||||||
|
fov = 90.0
|
|
@ -0,0 +1,24 @@
|
||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://system/character/character.tscn" type="PackedScene" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="CubeMesh" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape" id=2]
|
||||||
|
|
||||||
|
[node name="test" type="Spatial"]
|
||||||
|
|
||||||
|
[node name="Spatial" type="Spatial" parent="."]
|
||||||
|
transform = Transform( 4.96785, 0, 0, 0, 0.357803, 0, 0, 0, 4.45636, 0, 0, 0 )
|
||||||
|
|
||||||
|
[node name="ground" type="MeshInstance" parent="Spatial"]
|
||||||
|
mesh = SubResource( 1 )
|
||||||
|
material/0 = null
|
||||||
|
|
||||||
|
[node name="StaticBody" type="StaticBody" parent="Spatial/ground"]
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="Spatial/ground/StaticBody"]
|
||||||
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
|
[node name="Character" parent="." instance=ExtResource( 1 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.47987, 0 )
|
Loading…
Reference in New Issue
Block a user