fix: removing placing the 2d graphic on entities and changing it to a swipe for the knife
This commit is contained in:
@@ -4,6 +4,7 @@ class_name ImpactSpawner
|
||||
static var bullet_hole_mat: StandardMaterial3D = null
|
||||
static var crater_mat: StandardMaterial3D = null
|
||||
static var plasma_mat: StandardMaterial3D = null
|
||||
static var slash_mat: StandardMaterial3D = null
|
||||
|
||||
static func _ensure_mats():
|
||||
if bullet_hole_mat != null:
|
||||
@@ -52,12 +53,23 @@ static func _ensure_mats():
|
||||
plasma_mat.emission_texture = tex_p
|
||||
plasma_mat.emission_energy_multiplier = 2.0
|
||||
|
||||
var tex_s = make_tex.call(
|
||||
[Color(0.9, 0.9, 0.9, 1.0), Color(0.8, 0.8, 0.8, 0.8), Color(0.8, 0.8, 0.8, 0.0)],
|
||||
[0.0, 0.5, 1.0], 64)
|
||||
slash_mat = StandardMaterial3D.new()
|
||||
slash_mat.albedo_texture = tex_s
|
||||
slash_mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
|
||||
|
||||
static func spawn(scene_tree: SceneTree, type: String, pos: Vector3, normal: Vector3, size: float = 0.2):
|
||||
_ensure_mats()
|
||||
|
||||
var mi = MeshInstance3D.new()
|
||||
var qm = QuadMesh.new()
|
||||
qm.size = Vector2(size, size)
|
||||
|
||||
if type == "slash":
|
||||
qm.size = Vector2(size * 4.0, size * 0.4)
|
||||
else:
|
||||
qm.size = Vector2(size, size)
|
||||
|
||||
var mat: StandardMaterial3D
|
||||
if type == "bullet":
|
||||
@@ -66,6 +78,8 @@ static func spawn(scene_tree: SceneTree, type: String, pos: Vector3, normal: Vec
|
||||
mat = crater_mat.duplicate()
|
||||
elif type == "plasma":
|
||||
mat = plasma_mat.duplicate()
|
||||
elif type == "slash":
|
||||
mat = slash_mat.duplicate()
|
||||
|
||||
qm.material = mat
|
||||
mi.mesh = qm
|
||||
|
||||
+2
-2
@@ -162,8 +162,8 @@ func _do_damage() -> void:
|
||||
|
||||
if ray_result:
|
||||
var col = ray_result.collider
|
||||
if col is StaticBody3D or col is CSGShape3D:
|
||||
ImpactSpawner.spawn(get_tree(), "bullet", ray_result.position, ray_result.normal, 0.1)
|
||||
if not col.has_method("take_damage") and (col is StaticBody3D or col is CSGShape3D):
|
||||
ImpactSpawner.spawn(get_tree(), "slash", ray_result.position, ray_result.normal, 0.5)
|
||||
|
||||
func _finish_swing() -> void:
|
||||
is_swinging = false
|
||||
|
||||
Reference in New Issue
Block a user