Basic pathfinding working for crying ghosts
This commit is contained in:
10
Abilities/Fireball/Fireball.cs
Normal file
10
Abilities/Fireball/Fireball.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Fireball : ProjectileBase
|
||||
{
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
Position += Transform.X * Speed * (float)delta;
|
||||
}
|
||||
}
|
||||
1
Abilities/Fireball/Fireball.cs.uid
Normal file
1
Abilities/Fireball/Fireball.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://tt0u7f0gemjo
|
||||
BIN
Abilities/Fireball/Fireball.png
Normal file
BIN
Abilities/Fireball/Fireball.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 194 B |
40
Abilities/Fireball/Fireball.png.import
Normal file
40
Abilities/Fireball/Fireball.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://mesi0bfnca6y"
|
||||
path="res://.godot/imported/Fireball.png-220a164c89b06ee48fdd7fb2e948e296.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Abilities/Fireball/Fireball.png"
|
||||
dest_files=["res://.godot/imported/Fireball.png-220a164c89b06ee48fdd7fb2e948e296.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
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=1
|
||||
20
Abilities/Fireball/Fireball.tscn
Normal file
20
Abilities/Fireball/Fireball.tscn
Normal file
@@ -0,0 +1,20 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://bc7omt6pay1lx"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://tt0u7f0gemjo" path="res://Abilities/Fireball/Fireball.cs" id="1_0kqim"]
|
||||
[ext_resource type="Texture2D" uid="uid://mesi0bfnca6y" path="res://Abilities/Fireball/Fireball.png" id="2_rf7by"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_nvq50"]
|
||||
radius = 6.0
|
||||
|
||||
[node name="Fireball" type="Area2D"]
|
||||
script = ExtResource("1_0kqim")
|
||||
Speed = 700.0
|
||||
Lifetime = 1.0
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_rf7by")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_nvq50")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="OnBodyEntered"]
|
||||
34
Abilities/Fireball/Fireballv2.cs
Normal file
34
Abilities/Fireball/Fireballv2.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Fireballv2 : ProjectileBase
|
||||
{
|
||||
[Export] public float TurnRate { get; set; }
|
||||
[Export] public float OrbitStrength { get; set; }
|
||||
|
||||
Vector2 _velocity;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
var direction = (GetGlobalMousePosition() - GlobalPosition).Normalized();
|
||||
|
||||
_velocity = direction * Speed;
|
||||
Rotation = _velocity.Angle();
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
var targetDirection = (GetGlobalMousePosition() - GlobalPosition).Normalized();
|
||||
var perp = targetDirection.Orthogonal();
|
||||
|
||||
targetDirection = (targetDirection + perp * OrbitStrength).Normalized();
|
||||
var currentDirection = _velocity.Normalized();
|
||||
var angle = currentDirection.AngleTo(targetDirection);
|
||||
var maxTurn = TurnRate * (float)delta;
|
||||
|
||||
angle = Mathf.Clamp(angle, -maxTurn, maxTurn);
|
||||
_velocity = _velocity.Rotated(angle);
|
||||
GlobalPosition += _velocity * (float)delta;
|
||||
Rotation = _velocity.Angle();
|
||||
}
|
||||
}
|
||||
1
Abilities/Fireball/Fireballv2.cs.uid
Normal file
1
Abilities/Fireball/Fireballv2.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c4cmav4r8i83e
|
||||
22
Abilities/Fireball/Fireballv2.tscn
Normal file
22
Abilities/Fireball/Fireballv2.tscn
Normal file
@@ -0,0 +1,22 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://dhobg02glafch"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c4cmav4r8i83e" path="res://Abilities/Fireball/Fireballv2.cs" id="1_8mjwt"]
|
||||
[ext_resource type="Texture2D" uid="uid://mesi0bfnca6y" path="res://Abilities/Fireball/Fireball.png" id="2_0w1e3"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_nvq50"]
|
||||
radius = 6.0
|
||||
|
||||
[node name="Fireballv2" type="Area2D"]
|
||||
script = ExtResource("1_8mjwt")
|
||||
TurnRate = 8.0
|
||||
OrbitStrength = 1.0
|
||||
Speed = 500.0
|
||||
Lifetime = 1.0
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_0w1e3")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_nvq50")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="OnBodyEntered"]
|
||||
29
Abilities/Fireball/Fireballv3.cs
Normal file
29
Abilities/Fireball/Fireballv3.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Fireballv3 : ProjectileBase
|
||||
{
|
||||
[Export] public float TurnSpeed { get; set; }
|
||||
|
||||
Vector2 _velocity;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
var direction = (GetGlobalMousePosition() - GlobalPosition).Normalized();
|
||||
|
||||
_velocity = direction * Speed;
|
||||
Rotation = _velocity.Angle();
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
var targetDirection = (GetGlobalMousePosition() - GlobalPosition).Normalized();
|
||||
var currentDirection = _velocity.Normalized();
|
||||
var newDirection = currentDirection.Lerp(targetDirection, TurnSpeed * (float)delta).Normalized();
|
||||
|
||||
_velocity = newDirection * Speed;
|
||||
GlobalPosition += _velocity * (float)delta;
|
||||
Rotation = _velocity.Angle();
|
||||
}
|
||||
}
|
||||
1
Abilities/Fireball/Fireballv3.cs.uid
Normal file
1
Abilities/Fireball/Fireballv3.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bwwxti5v178gx
|
||||
21
Abilities/Fireball/Fireballv3.tscn
Normal file
21
Abilities/Fireball/Fireballv3.tscn
Normal file
@@ -0,0 +1,21 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://b2u2xirxjo68h"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bwwxti5v178gx" path="res://Abilities/Fireball/Fireballv3.cs" id="1_8c7o3"]
|
||||
[ext_resource type="Texture2D" uid="uid://mesi0bfnca6y" path="res://Abilities/Fireball/Fireball.png" id="2_aknci"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_nvq50"]
|
||||
radius = 6.0
|
||||
|
||||
[node name="Fireballv3" type="Area2D"]
|
||||
script = ExtResource("1_8c7o3")
|
||||
TurnSpeed = 8.0
|
||||
Speed = 500.0
|
||||
Lifetime = 1.0
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_aknci")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_nvq50")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="OnBodyEntered"]
|
||||
Reference in New Issue
Block a user