mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-22 19:43:55 +00:00
Rotating 3D chairs
This commit is contained in:
parent
5c9f592cc3
commit
f7448eb3f5
5 changed files with 232 additions and 147 deletions
|
|
@ -650,3 +650,13 @@
|
||||||
"origin" "124 172 60"
|
"origin" "124 172 60"
|
||||||
"target" "elevator_test"
|
"target" "elevator_test"
|
||||||
}
|
}
|
||||||
|
// entity 11
|
||||||
|
{
|
||||||
|
"classname" "actor_chair"
|
||||||
|
"origin" "-24 -32 24"
|
||||||
|
}
|
||||||
|
// entity 12
|
||||||
|
{
|
||||||
|
"classname" "actor_chair"
|
||||||
|
"origin" "16 -40 24"
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,20 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://dmwtysh7eijon"]
|
[gd_scene load_steps=5 format=3 uid="uid://dmwtysh7eijon"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://ccxnvbthsvka3" path="res://Scripts/Actors/Destructible3D.cs" id="1_q4vm8"]
|
[ext_resource type="Script" uid="uid://46bleylruayt" path="res://Scripts/Actors/3D/Chair3D.cs" id="1_lak88"]
|
||||||
[ext_resource type="Resource" uid="uid://bpreje4f8ok62" path="res://Resources/Bullets/3D/Explosion_3D.tres" id="2_hbvng"]
|
|
||||||
[ext_resource type="Script" uid="uid://ddsqqfx1usc3j" path="res://Scripts/Resources/DamageResistance.cs" id="3_jiv17"]
|
|
||||||
[ext_resource type="SpriteFrames" uid="uid://sg77hbw6lo6r" path="res://Resources/Sprites/Chair.tres" id="5_265cv"]
|
[ext_resource type="SpriteFrames" uid="uid://sg77hbw6lo6r" path="res://Resources/Sprites/Chair.tres" id="5_265cv"]
|
||||||
|
|
||||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_2libs"]
|
[sub_resource type="CylinderShape3D" id="CylinderShape3D_2libs"]
|
||||||
height = 0.564575
|
height = 0.564575
|
||||||
radius = 0.321777
|
radius = 0.321777
|
||||||
|
|
||||||
|
[sub_resource type="CylinderShape3D" id="CylinderShape3D_q4vm8"]
|
||||||
|
height = 0.5595703
|
||||||
|
radius = 0.3227539
|
||||||
|
|
||||||
[node name="StaticBody3D" type="StaticBody3D" groups=["Destroyable"]]
|
[node name="StaticBody3D" type="StaticBody3D" groups=["Destroyable"]]
|
||||||
collision_layer = 16
|
collision_layer = 16
|
||||||
collision_mask = 0
|
collision_mask = 0
|
||||||
script = ExtResource("1_q4vm8")
|
script = ExtResource("1_lak88")
|
||||||
Indestructible = true
|
|
||||||
ExplosionData = ExtResource("2_hbvng")
|
|
||||||
DamageResistances = Array[ExtResource("3_jiv17")]([])
|
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0376587, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0376587, 0)
|
||||||
|
|
@ -26,5 +25,15 @@ transform = Transform3D(0.70710677, -0.49999997, 0.49999997, 0, 0.70710677, 0.70
|
||||||
pixel_size = 0.05
|
pixel_size = 0.05
|
||||||
texture_filter = 0
|
texture_filter = 0
|
||||||
sprite_frames = ExtResource("5_265cv")
|
sprite_frames = ExtResource("5_265cv")
|
||||||
animation = &"Spin"
|
animation = &"Down"
|
||||||
frame_progress = 0.36955565
|
autoplay = "Down"
|
||||||
|
|
||||||
|
[node name="Area3D" type="Area3D" parent="."]
|
||||||
|
collision_layer = 0
|
||||||
|
collision_mask = 136
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.029785156, 0)
|
||||||
|
shape = SubResource("CylinderShape3D_q4vm8")
|
||||||
|
|
||||||
|
[connection signal="area_entered" from="Area3D" to="." method="OnBulletCollision"]
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
58
Scripts/Actors/3D/Chair3D.cs
Normal file
58
Scripts/Actors/3D/Chair3D.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
using System;
|
||||||
|
using Cirno.Scripts.Enums;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Cirno.Scripts.Actors._3D;
|
||||||
|
|
||||||
|
[Tool]
|
||||||
|
public partial class Chair3D : StaticBody3D
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
public Direction Direction { get; set; } = Direction.Down;
|
||||||
|
private AnimatedSprite3D _animatedSprite;
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public StringName SpinAnimationName = "Spin";
|
||||||
|
|
||||||
|
[Export] public float SpinTime { get; private set; } = 4f;
|
||||||
|
|
||||||
|
private double _timer = 0f;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
_animatedSprite = GetNode<AnimatedSprite3D>("AnimatedSprite3D");
|
||||||
|
|
||||||
|
_animatedSprite.Play(Direction.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Process(double delta)
|
||||||
|
{
|
||||||
|
if (Engine.IsEditorHint()) return;
|
||||||
|
|
||||||
|
if (_animatedSprite.Animation != SpinAnimationName) return;
|
||||||
|
_timer += delta;
|
||||||
|
|
||||||
|
if (_timer >= SpinTime)
|
||||||
|
{
|
||||||
|
_timer = 0;
|
||||||
|
_animatedSprite.SpeedScale = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnBulletCollision(Area3D area)
|
||||||
|
{
|
||||||
|
_animatedSprite.SpeedScale = 1;
|
||||||
|
_animatedSprite.Play("Spin");
|
||||||
|
|
||||||
|
_timer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Direction GetRandomDirection()
|
||||||
|
{
|
||||||
|
var directions = (Direction[])Enum.GetValues(typeof(Direction));
|
||||||
|
|
||||||
|
//GD.RandRange(0, directions.Length -1);
|
||||||
|
return directions[GD.RandRange(0, directions.Length - 1)];
|
||||||
|
}
|
||||||
|
}
|
||||||
1
Scripts/Actors/3D/Chair3D.cs.uid
Normal file
1
Scripts/Actors/3D/Chair3D.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://46bleylruayt
|
||||||
Loading…
Add table
Add a link
Reference in a new issue