7 changed files with 318 additions and 8 deletions
			
			
		| @ -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") | ||||||
| @ -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) ; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -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; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| After Width: | Height: | Size: 4.1 MiB | 
| @ -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 | ||||||
					Loading…
					
					
				
		Reference in new issue