Lotos Changes
Made Disc handled By Playert
Added Throw State (handle it better soon™️)
Added basic example animation that increases in speed as you move
This commit is contained in:
14
3d_test.gd
14
3d_test.gd
@@ -1,17 +1,15 @@
|
|||||||
extends Node3D
|
extends Node3D
|
||||||
|
|
||||||
const Disc = preload("res://disc.tscn")
|
var DebugScene = preload("res://DebugUI.tscn").instantiate()
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
pass # Replace with function body.
|
get_tree().root.add_child(DebugScene)
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if event.is_action_pressed("player_jump"):
|
if event.is_action_pressed("ui_menu"):
|
||||||
var disc = Disc.instantiate()
|
pass
|
||||||
disc.position = $Player/Torso/RightArm/Hand.global_position
|
|
||||||
add_child(disc)
|
|
||||||
disc.apply_impulse(Vector3(0,10,0))
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
pass
|
$CameraCenter.position = $Player.position
|
||||||
|
|||||||
10
3d_test.tscn
10
3d_test.tscn
@@ -15,10 +15,7 @@ shadow_enabled = true
|
|||||||
directional_shadow_pancake_size = 0.0
|
directional_shadow_pancake_size = 0.0
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource("1_osef0")]
|
[node name="Player" parent="." instance=ExtResource("1_osef0")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.58914, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.58914, -2.38419e-07)
|
||||||
|
|
||||||
[node name="Camera3D" type="Camera3D" parent="Player"]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 0.979855, 0.19971, 0, -0.19971, 0.979855, 0, 1.43735, 2.24099)
|
|
||||||
|
|
||||||
[node name="TestTerrain" parent="." instance=ExtResource("2_3miw1")]
|
[node name="TestTerrain" parent="." instance=ExtResource("2_3miw1")]
|
||||||
script = ExtResource("3_15ip2")
|
script = ExtResource("3_15ip2")
|
||||||
@@ -34,3 +31,8 @@ transform = Transform3D(1, 0, 0, 0, -1, -8.74228e-08, 0, 8.74228e-08, -1, 0, 0.8
|
|||||||
|
|
||||||
[node name="Box4" parent="." instance=ExtResource("3_qc72a")]
|
[node name="Box4" parent="." instance=ExtResource("3_qc72a")]
|
||||||
transform = Transform3D(1, 0, 0, 0, -1, -8.74228e-08, 0, 8.74228e-08, -1, -10.006, 0.829506, -6)
|
transform = Transform3D(1, 0, 0, 0, -1, -8.74228e-08, 0, 8.74228e-08, -1, -10.006, 0.829506, -6)
|
||||||
|
|
||||||
|
[node name="CameraCenter" type="Node3D" parent="."]
|
||||||
|
|
||||||
|
[node name="CameraView" type="Camera3D" parent="CameraCenter"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 0.979855, 0.19971, 0, -0.19971, 0.979855, 0, 2.02649, 2.24099)
|
||||||
|
|||||||
15
DebugUI.tscn
Normal file
15
DebugUI.tscn
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[gd_scene format=3 uid="uid://bnsajfwanp0gv"]
|
||||||
|
|
||||||
|
[node name="Control" type="Control"]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="."]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_right = 592.0
|
||||||
|
offset_bottom = 290.0
|
||||||
|
color = Color(0.516236, 0.215923, 1, 1)
|
||||||
@@ -10,6 +10,8 @@ height = 0.05
|
|||||||
radius = 0.25
|
radius = 0.25
|
||||||
|
|
||||||
[node name="Disc" type="RigidBody3D"]
|
[node name="Disc" type="RigidBody3D"]
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 5
|
||||||
|
|
||||||
[node name="Model" type="MeshInstance3D" parent="."]
|
[node name="Model" type="MeshInstance3D" parent="."]
|
||||||
mesh = SubResource("CylinderMesh_f68ox")
|
mesh = SubResource("CylinderMesh_f68ox")
|
||||||
|
|||||||
44
player3d.gd
44
player3d.gd
@@ -5,11 +5,28 @@ var remote_player = false
|
|||||||
const SPEED = 5.0
|
const SPEED = 5.0
|
||||||
const JUMP_VELOCITY = 4.5
|
const JUMP_VELOCITY = 4.5
|
||||||
|
|
||||||
|
const Disc = preload("res://disc.tscn")
|
||||||
|
var heldItem = null
|
||||||
|
|
||||||
# Get the gravity from the project settings to be synced with RigidBody nodes.
|
# Get the gravity from the project settings to be synced with RigidBody nodes.
|
||||||
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
|
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
|
||||||
|
|
||||||
|
# TODO: Add Tween for rotation, maybe
|
||||||
|
func enterThrowMode():
|
||||||
|
$Torso.rotation_degrees.y = 110
|
||||||
|
|
||||||
|
# TODO: Add Tweens between modes
|
||||||
|
func leaveThroeMode():
|
||||||
|
rotation.y = 0
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
pass
|
if Input.is_action_pressed("player_taunt"):
|
||||||
|
enterThrowMode()
|
||||||
|
if heldItem == null:
|
||||||
|
heldItem = Disc.instantiate()
|
||||||
|
heldItem.freeze_mode = RigidBody3D.FREEZE_MODE_STATIC
|
||||||
|
heldItem.freeze = true
|
||||||
|
$Torso/RightArm/Hand.add_child(heldItem)
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
# Add the gravity.
|
# Add the gravity.
|
||||||
@@ -21,10 +38,9 @@ func _physics_process(delta):
|
|||||||
velocity.y = JUMP_VELOCITY
|
velocity.y = JUMP_VELOCITY
|
||||||
|
|
||||||
# Get the input direction and handle the movement/deceleration.
|
# Get the input direction and handle the movement/deceleration.
|
||||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
|
||||||
var input_dir = Input.get_vector("player_left", "player_right", "player_up", "player_down")
|
var input_dir = Input.get_vector("player_left", "player_right", "player_up", "player_down")
|
||||||
|
|
||||||
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y))
|
||||||
if direction:
|
if direction:
|
||||||
velocity.x = direction.x * SPEED
|
velocity.x = direction.x * SPEED
|
||||||
velocity.z = direction.z * SPEED
|
velocity.z = direction.z * SPEED
|
||||||
@@ -42,8 +58,24 @@ func _physics_process(delta):
|
|||||||
var flick_ang :float= 0
|
var flick_ang :float= 0
|
||||||
if flick.length_squared() != 0:
|
if flick.length_squared() != 0:
|
||||||
flick_ang = flick.angle()
|
flick_ang = flick.angle()
|
||||||
var flick_rot = Vector3(0,0,flick_ang)
|
|
||||||
$Torso/LeftArm.rotation = flick_rot
|
if heldItem == null:
|
||||||
$Torso/RightArm.rotation = -flick_rot
|
var flick_rot = Vector3(0,0,flick_ang)
|
||||||
|
$Torso/LeftArm.rotation = flick_rot
|
||||||
|
$Torso/RightArm.rotation = -flick_rot
|
||||||
|
else:
|
||||||
|
var flick_rot = Vector3(0,flick_ang - PI/4,0)
|
||||||
|
$Torso/LeftArm.rotation_degrees.z = 70
|
||||||
|
$Torso/RightArm.rotation.y = clamp(flick_ang,0,PI/2)
|
||||||
|
|
||||||
|
var speed = velocity.length()
|
||||||
|
|
||||||
|
if speed > 0:
|
||||||
|
$Running.speed_scale = speed/SPEED*3
|
||||||
|
$Running.play("player_run")
|
||||||
|
else:
|
||||||
|
var stop_tween :Tween= $Running.create_tween()
|
||||||
|
$Running.stop(true)
|
||||||
|
stop_tween.tween_property(self, "rotation", Vector3(0,0,0), 0.2)
|
||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=6 format=3 uid="uid://ctgbbvgfnocql"]
|
[gd_scene load_steps=9 format=3 uid="uid://ctgbbvgfnocql"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://player3d.gd" id="1_8eds3"]
|
[ext_resource type="Script" path="res://player3d.gd" id="1_8eds3"]
|
||||||
|
|
||||||
@@ -14,6 +14,43 @@ height = 1.25
|
|||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_1okp8"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_1okp8"]
|
||||||
radius = 0.25
|
radius = 0.25
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_s653s"]
|
||||||
|
resource_name = "player_run"
|
||||||
|
length = 2.0
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath(".:rotation")
|
||||||
|
tracks/0/interp = 2
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.5, 1, 1.5, 2),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector3(0, 0, 0), Vector3(0, 0, -0.261799), Vector3(0, 0, -2.98023e-08), Vector3(0, 0, 0.261799), Vector3(0, 0, -1.49012e-08)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_wbwlv"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath(".:rotation")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector3(0, 0, 0)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_aq07q"]
|
||||||
|
_data = {
|
||||||
|
"RESET": SubResource("Animation_wbwlv"),
|
||||||
|
"player_run": SubResource("Animation_s653s")
|
||||||
|
}
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody3D"]
|
[node name="Player" type="CharacterBody3D"]
|
||||||
script = ExtResource("1_8eds3")
|
script = ExtResource("1_8eds3")
|
||||||
|
|
||||||
@@ -56,3 +93,9 @@ collision_mask = 2
|
|||||||
|
|
||||||
[node name="Hand" type="CollisionShape3D" parent="Torso/RightArm/Hand"]
|
[node name="Hand" type="CollisionShape3D" parent="Torso/RightArm/Hand"]
|
||||||
shape = SubResource("SphereShape3D_1okp8")
|
shape = SubResource("SphereShape3D_1okp8")
|
||||||
|
|
||||||
|
[node name="Running" type="AnimationPlayer" parent="."]
|
||||||
|
speed_scale = 2.0
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_aq07q")
|
||||||
|
}
|
||||||
|
|||||||
@@ -79,6 +79,11 @@ flick_down={
|
|||||||
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
|
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
player_taunt={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":3,"pressure":0.0,"pressed":true,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user