Browse Source

fixed Action3D Example

master
jkpete 4 months ago
parent
commit
cc79a0a53f
  1. 110
      Example/Action3D/MainGame.tscn
  2. 46
      Example/Action3D/Script/ActionCamera.cs
  3. 62
      Example/Action3D/Script/ActionPlayer.cs
  4. BIN
      Example/Action3D/SkyBox/lakeside.jpg
  5. 35
      Example/Action3D/SkyBox/lakeside.jpg.import
  6. 13
      icon.svg.import
  7. 60
      project.godot

110
Example/Action3D/MainGame.tscn

@ -0,0 +1,110 @@ @@ -0,0 +1,110 @@
[gd_scene load_steps=19 format=3 uid="uid://05atvgqt8tku"]
[ext_resource type="Texture2D" uid="uid://ss8dh8aaqc4w" path="res://Example/Action3D/SkyBox/lakeside.jpg" id="1_akq3m"]
[ext_resource type="Texture2D" uid="uid://31r216hix0wk" path="res://icon.svg" id="2_b66wh"]
[ext_resource type="Script" path="res://Example/Action3D/Script/ActionPlayer.cs" id="2_c0s4j"]
[ext_resource type="Script" path="res://Example/Action3D/Script/ActionCamera.cs" id="3_ue0e3"]
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_hbme1"]
panorama = ExtResource("1_akq3m")
[sub_resource type="Sky" id="Sky_qmmlv"]
sky_material = SubResource("PanoramaSkyMaterial_hbme1")
[sub_resource type="Environment" id="Environment_dusyb"]
background_mode = 2
sky = SubResource("Sky_qmmlv")
glow_enabled = true
fog_light_color = Color(0.152941, 0.168627, 0.196078, 1)
fog_density = 0.05
fog_aerial_perspective = 1.0
fog_height = 0.5
fog_height_density = 0.4
adjustment_brightness = 1.91
[sub_resource type="BoxShape3D" id="BoxShape3D_hm8uo"]
size = Vector3(60, 1, 60)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_c0bvn"]
albedo_texture = ExtResource("2_b66wh")
[sub_resource type="BoxMesh" id="BoxMesh_2gv65"]
material = SubResource("StandardMaterial3D_c0bvn")
size = Vector3(60, 1, 60)
[sub_resource type="BoxShape3D" id="BoxShape3D_4jggu"]
[sub_resource type="BoxShape3D" id="BoxShape3D_7005m"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_byd0k"]
albedo_color = Color(0, 0.219608, 0.176471, 1)
[sub_resource type="BoxMesh" id="BoxMesh_h3y2r"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_r4ehu"]
albedo_color = Color(0.517647, 0.886275, 0.807843, 1)
rim_enabled = true
rim_tint = 0.48
[sub_resource type="BoxMesh" id="BoxMesh_3o4en"]
material = SubResource("StandardMaterial3D_r4ehu")
size = Vector3(0.5, 0.5, 0.5)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_dv57j"]
albedo_color = Color(0.294118, 0.294118, 0.294118, 1)
metallic = 1.0
metallic_specular = 1.0
[sub_resource type="BoxMesh" id="BoxMesh_iv7ly"]
material = SubResource("StandardMaterial3D_dv57j")
size = Vector3(0.6, 0.6, 0.6)
[node name="MainGame" type="Node3D"]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_dusyb")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.642788, -0.383022, 0.663414, 0, 0.866025, 0.5, -0.766044, -0.321394, 0.55667, 0, 0, 0)
shadow_enabled = true
[node name="Ground" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.01419, 0)
[node name="CollisionShape3D" type="CollisionShape3D" parent="Ground"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00709915, 0.117098, -0.180923)
shape = SubResource("BoxShape3D_hm8uo")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Ground"]
mesh = SubResource("BoxMesh_2gv65")
[node name="Area3D" type="Area3D" parent="."]
visible = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
shape = SubResource("BoxShape3D_4jggu")
[node name="Pivot" type="Node3D" parent="."]
script = ExtResource("3_ue0e3")
[node name="Camera3D" type="Camera3D" parent="Pivot"]
transform = Transform3D(1, 0, 0, 0, 0.976296, 0.21644, 0, -0.21644, 0.976296, 0, 1, 2)
[node name="Player" type="CharacterBody3D" parent="."]
script = ExtResource("2_c0s4j")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Player"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0296049, -9.53674e-07, 0.00402832)
shape = SubResource("BoxShape3D_7005m")
[node name="Body" type="MeshInstance3D" parent="Player"]
material_override = SubResource("StandardMaterial3D_byd0k")
mesh = SubResource("BoxMesh_h3y2r")
[node name="Head" type="MeshInstance3D" parent="Player/Body"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.75, 0)
mesh = SubResource("BoxMesh_3o4en")
[node name="Hair" type="MeshInstance3D" parent="Player/Body"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0.15)
mesh = SubResource("BoxMesh_iv7ly")

46
Example/Action3D/Script/ActionCamera.cs

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
using Godot;
using System;
public partial class ActionCamera : Node3D
{
[Export]
public float Speed { get; set; } = 4;
private Vector3 _targetRotation = Vector3.Zero;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
public override void _PhysicsProcess(double delta)
{
if (Input.IsActionPressed("camera_up"))
{
_targetRotation.X -= Speed*(float)delta;
}
if (Input.IsActionPressed("camera_down"))
{
_targetRotation.X += Speed*(float)delta;
}
if (Input.IsActionPressed("camera_left"))
{
_targetRotation.Y -= Speed*(float)delta;
}
if (Input.IsActionPressed("camera_right"))
{
_targetRotation.Y += Speed*(float)delta;
}
if (_targetRotation.X>30*Mathf.Pi/180)
{
_targetRotation.X = 30*Mathf.Pi/180;
}
if (_targetRotation.X<-30*Mathf.Pi/180){
_targetRotation.X = -30*Mathf.Pi/180;
}
this.Rotation = this.Rotation.Lerp(_targetRotation,Speed*(float)delta) ;
}
}

62
Example/Action3D/Script/ActionPlayer.cs

@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
using Godot;
using System;
namespace EGFramework.Examples.Action3D{
public partial class ActionPlayer : CharacterBody3D
{
[Export]
public int Speed { get; set; } = 14;
[Export]
public int FallAcceleration { get; set; } = 75;
private Vector3 _targetVelocity = Vector3.Zero;
public Node3D CameraPivot { set; get; }
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
CameraPivot = this.GetNode<Node3D>("../Pivot");
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
public override void _PhysicsProcess(double delta)
{
// We create a local variable to store the input direction.
var direction = Vector3.Zero;
direction.X = Input.GetAxis("move_left", "move_right");
direction.Z = Input.GetAxis("move_forward", "move_back");
if (direction.Length() > 0)
{
this.Rotation = new Vector3(0,CameraPivot.Rotation.Y,0);
direction = direction.Normalized();
direction = direction.Rotated(Vector3.Up, CameraPivot.Rotation.Y);
}
// direction.Rotated(Vector3.Up, CameraPivot.Rotation.Y);
// Ground velocity
_targetVelocity.X = direction.X * Speed;
_targetVelocity.Z = direction.Z * Speed;
if (!IsOnFloor()) // If in the air, fall towards the floor. Literally gravity
{
// GD.Print("Fallen!");
_targetVelocity.Y -= FallAcceleration * (float)delta;
}else{
if (Input.IsActionPressed("jump"))
{
_targetVelocity.Y += 10.0f;
}
}
this.Velocity = _targetVelocity;
MoveAndSlide();
CameraPivot.Position = this.Position;
}
}
}

BIN
Example/Action3D/SkyBox/lakeside.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 MiB

35
Example/Action3D/SkyBox/lakeside.jpg.import

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ss8dh8aaqc4w"
path.s3tc="res://.godot/imported/lakeside.jpg-33a4031d53286dbc1f7dd66477cda464.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://Example/Action3D/SkyBox/lakeside.jpg"
dest_files=["res://.godot/imported/lakeside.jpg-33a4031d53286dbc1f7dd66477cda464.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=0

13
icon.svg.import

@ -3,25 +3,26 @@ @@ -3,25 +3,26 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://31r216hix0wk"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
path.s3tc="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"
metadata={
"vram_texture": false
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"]
[params]
compress/mode=0
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
@ -31,7 +32,7 @@ process/normal_map_invert_y=false @@ -31,7 +32,7 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

60
project.godot

@ -12,7 +12,7 @@ config_version=5 @@ -12,7 +12,7 @@ config_version=5
config/name="EGFramework"
config/tags=PackedStringArray("official")
run/main_scene="res://Example/Tween/EGTween.tscn"
run/main_scene="res://Example/Action3D/MainGame.tscn"
config/features=PackedStringArray("4.2", "C#", "GL Compatibility")
config/icon="res://icon.svg"
@ -20,7 +20,63 @@ config/icon="res://icon.svg" @@ -20,7 +20,63 @@ config/icon="res://icon.svg"
project/assembly_name="EGFramework"
[input]
move_forward={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
]
}
move_back={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
]
}
move_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
]
}
move_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
]
}
camera_up={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)
]
}
camera_down={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
]
}
camera_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":-1.0,"script":null)
]
}
camera_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null)
]
}
jump={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"script":null)
]
}
[rendering]
renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"

Loading…
Cancel
Save