summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2022-09-12 02:11:27 -0400
committerMalfurious <m@lfurio.us>2022-09-12 02:11:27 -0400
commit40a9b7b7fb7d6e0312ae610b527d18fb2d708ba7 (patch)
treefe6dd1fbffaa093fc55aec747c22a8b350aa85f8
parentf44398ea774c171d9aa0f274f603101c7a1186b9 (diff)
downloadproject-s-40a9b7b7fb7d6e0312ae610b527d18fb2d708ba7.tar.gz
project-s-40a9b7b7fb7d6e0312ae610b527d18fb2d708ba7.zip
Decouple ViewModel and the BaseCharacter
The ViewModel now consists of the camera, controls, and character driving logic. The actual character model has been removed and is expected to be externally present in the scene. An exported variable is added to reference the player object that the view model is to be controlling. This will allow us to place multiple characters in a scene and change the view model's perspective on the fly. Both of the current maps have been updated to implement this properly, and add an extra character on the enemy team. Signed-off-by: Malfurious <m@lfurio.us>
-rw-r--r--assets/maps/misc/dev_plane/DevPlane.tscn17
-rw-r--r--assets/maps/misc/test_map/shipping_yard_map.tscn17
-rw-r--r--assets/view_model/ViewModel.gd2
-rw-r--r--assets/view_model/ViewModel.tscn5
4 files changed, 28 insertions, 13 deletions
diff --git a/assets/maps/misc/dev_plane/DevPlane.tscn b/assets/maps/misc/dev_plane/DevPlane.tscn
index a17a112..5134d2e 100644
--- a/assets/maps/misc/dev_plane/DevPlane.tscn
+++ b/assets/maps/misc/dev_plane/DevPlane.tscn
@@ -1,7 +1,9 @@
-[gd_scene load_steps=9 format=2]
+[gd_scene load_steps=11 format=2]
[ext_resource path="res://assets/maps/misc/dev_plane/tile_color.png" type="Texture" id=1]
[ext_resource path="res://assets/view_model/ViewModel.tscn" type="PackedScene" id=2]
+[ext_resource path="res://assets/characters/base_character/BaseCharacter.tscn" type="PackedScene" id=3]
+[ext_resource path="res://assets/characters/base_character/enemy_material.tres" type="Material" id=4]
[sub_resource type="SpatialMaterial" id=6]
albedo_texture = ExtResource( 1 )
@@ -25,14 +27,21 @@ material = SubResource( 3 )
[node name="DevPlane" type="Spatial"]
+[node name="ViewModel" parent="." instance=ExtResource( 2 )]
+character = NodePath("../FriendlyPlayer")
+
+[node name="FriendlyPlayer" parent="." groups=["players"] instance=ExtResource( 3 )]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.75, 12 )
+
+[node name="EnemyPlayer" parent="." groups=["players"] instance=ExtResource( 3 )]
+transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0.75, -12 )
+material = ExtResource( 4 )
+
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( -4.37114e-08, -0.292372, 0.956305, 0, 0.956305, 0.292372, -1, 1.278e-08, -4.18014e-08, 0, 10, 0 )
shadow_enabled = true
directional_shadow_blend_splits = true
-[node name="ViewModel" parent="." instance=ExtResource( 2 )]
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 12 )
-
[node name="Geometry" type="Spatial" parent="."]
[node name="Floor" type="StaticBody" parent="Geometry"]
diff --git a/assets/maps/misc/test_map/shipping_yard_map.tscn b/assets/maps/misc/test_map/shipping_yard_map.tscn
index f2c5efb..f5cf4eb 100644
--- a/assets/maps/misc/test_map/shipping_yard_map.tscn
+++ b/assets/maps/misc/test_map/shipping_yard_map.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=63 format=2]
+[gd_scene load_steps=65 format=2]
[ext_resource path="res://assets/maps/misc/test_map/test_map_assets/shipping_containers/red_malfurious_container/red_malfurious_container.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/maps/misc/test_map/test_map_assets/platforms/supports/support_01.tscn" type="PackedScene" id=2]
@@ -36,6 +36,8 @@
[ext_resource path="res://custom_shaders/liquid.gdshader" type="Shader" id=34]
[ext_resource path="res://assets/maps/misc/test_map/test_map_assets/environment/buildings/building_1/building_1.tscn" type="PackedScene" id=35]
[ext_resource path="res://assets/maps/misc/test_map/test_map_assets/decals/ftf_graffiti.tscn" type="PackedScene" id=36]
+[ext_resource path="res://assets/characters/base_character/BaseCharacter.tscn" type="PackedScene" id=37]
+[ext_resource path="res://assets/characters/base_character/enemy_material.tres" type="Material" id=38]
[sub_resource type="ArrayMesh" id=1]
resource_name = "crane_load_Cylinder002"
@@ -313,6 +315,16 @@ polygon_points = PoolVector2Array( 1.17958, -3.9844, 1.18686, 1.20034, -1.04211,
[node name="shipping_yard_map" type="Spatial"]
+[node name="ViewModel" parent="." instance=ExtResource( 11 )]
+character = NodePath("../FriendlyPlayer")
+
+[node name="FriendlyPlayer" parent="." groups=["players"] instance=ExtResource( 37 )]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.066, 105.317 )
+
+[node name="EnemyPlayer" parent="." groups=["players"] instance=ExtResource( 37 )]
+transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 2.066, -105.317 )
+material = ExtResource( 38 )
+
[node name="left_side" type="Spatial" parent="."]
[node name="shipping_yard_main_terrain" parent="left_side" instance=ExtResource( 6 )]
@@ -1318,9 +1330,6 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.859604, 0, 34.7394 )
[node name="ftf_graffiti" parent="decorative/non_symmetrical_graffiti" instance=ExtResource( 36 )]
transform = Transform( -4.37114e-08, -1, 4.37114e-08, 0.05007, -4.58452e-08, -0.998746, 0.998746, -4.14679e-08, 0.05007, 20.2422, 2.83189, 37.9582 )
-[node name="ViewModel" parent="." instance=ExtResource( 11 )]
-transform = Transform( 1, 0, 1.74846e-07, 0, 1, 0, -1.74846e-07, 0, 1, 0, 2.06622, 105.317 )
-
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = ExtResource( 21 )
diff --git a/assets/view_model/ViewModel.gd b/assets/view_model/ViewModel.gd
index cb85117..8a818a3 100644
--- a/assets/view_model/ViewModel.gd
+++ b/assets/view_model/ViewModel.gd
@@ -8,7 +8,7 @@ export var gravity = 35
var velocity = Vector3.ZERO
var snap = Vector3.DOWN
-onready var character = $BaseCharacter
+export(NodePath) onready var character = get_node(character)
onready var anchor = $Anchor
onready var spring_arm = $Anchor/SpringArm
onready var fps_label = $fps_label
diff --git a/assets/view_model/ViewModel.tscn b/assets/view_model/ViewModel.tscn
index 0267e64..f5d3118 100644
--- a/assets/view_model/ViewModel.tscn
+++ b/assets/view_model/ViewModel.tscn
@@ -1,14 +1,11 @@
-[gd_scene load_steps=3 format=2]
+[gd_scene load_steps=2 format=2]
-[ext_resource path="res://assets/characters/base_character/BaseCharacter.tscn" type="PackedScene" id=1]
[ext_resource path="res://assets/view_model/ViewModel.gd" type="Script" id=2]
[node name="ViewModel" type="Spatial"]
script = ExtResource( 2 )
aim_sensitivity = 0.04
-[node name="BaseCharacter" parent="." instance=ExtResource( 1 )]
-
[node name="Anchor" type="Spatial" parent="."]
[node name="SpringArm" type="SpringArm" parent="Anchor"]