This repository has been archived by the owner on Aug 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented DamageIndicators for hitscan weapons
Damage Indicators now work perfectly
- Loading branch information
1 parent
f952b97
commit a57e552
Showing
9 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Godot; | ||
using System; | ||
|
||
public class DamageIndicator : TextureRect | ||
{ | ||
// Angle the bullet came from | ||
Vector2 ShotFirePosition; | ||
float OriginalAngle; | ||
public override void _Ready() | ||
{ | ||
// Start transparency Tween in _Ready so we know the Tween has been created | ||
Tween TransparencyTween = GetNode<Tween>("Tween"); | ||
// Tween the "modulate" property | ||
TransparencyTween.InterpolateProperty(this,"modulate", new Color(255,255,255,1), new Color(255,255,255,0), 3, Tween.TransitionType.Linear, Tween.EaseType.InOut); | ||
TransparencyTween.Start(); | ||
} | ||
|
||
|
||
public void SetTargetAngle(Vector2 ShotFirePosition) | ||
{ | ||
// The rotation we're looking at is the Y rotation | ||
this.ShotFirePosition = ShotFirePosition; | ||
// Original angle | ||
OriginalAngle = Game.PossessedPlayer.Rotation.y; | ||
} | ||
|
||
|
||
// Called every frame. 'delta' is the elapsed time since the previous frame. | ||
public override void _Process(float delta) | ||
{ | ||
// Calculate rotation | ||
// Calculate our position on a 2D plane | ||
Vector2 OurPoint = new Vector2(Game.PossessedPlayer.Translation.x, Game.PossessedPlayer.Translation.z); | ||
// Get our rotation by getting the angle from where we we're shot from, and adding where we we're looking before | ||
RectRotation = Mathf.Rad2Deg(OurPoint.AngleToPoint(ShotFirePosition)+OriginalAngle); | ||
} | ||
|
||
|
||
public void TweenComplete() | ||
{ | ||
// We're now totally transparent, so time to | ||
QueueFree(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[gd_scene load_steps=3 format=2] | ||
|
||
[ext_resource path="res://UI/Textures/DamageIndicator.png" type="Texture" id=1] | ||
[ext_resource path="res://UI/DamageIndicator.cs" type="Script" id=2] | ||
|
||
[node name="DamageIndicator" type="TextureRect"] | ||
margin_left = 312.0 | ||
margin_top = 100.0 | ||
margin_right = 712.0 | ||
margin_bottom = 500.0 | ||
rect_pivot_offset = Vector2( 200, 200 ) | ||
texture = ExtResource( 1 ) | ||
script = ExtResource( 2 ) | ||
|
||
[node name="Tween" type="Tween" parent="."] | ||
[connection signal="tween_all_completed" from="Tween" to="." method="TweenComplete"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="StreamTexture" | ||
path="res://.import/DamageIndicator.png-cbb494ba511e14f2e40bf5115c6800de.stex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://UI/Textures/DamageIndicator.png" | ||
dest_files=[ "res://.import/DamageIndicator.png-cbb494ba511e14f2e40bf5115c6800de.stex" ] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/lossy_quality=0.7 | ||
compress/hdr_mode=0 | ||
compress/bptc_ldr=0 | ||
compress/normal_map=0 | ||
flags/repeat=0 | ||
flags/filter=true | ||
flags/mipmaps=false | ||
flags/anisotropic=false | ||
flags/srgb=2 | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/HDR_as_SRGB=false | ||
process/invert_color=false | ||
stream=false | ||
size_limit=0 | ||
detect_3d=true | ||
svg/scale=1.0 |