forked from unfa/liblast
Fixed rockets phasing trhough walls. no splash damage yet.
parent
a661669d2f
commit
aa340bc628
|
@ -29,10 +29,13 @@ func _ready():
|
|||
#$OmniLight3D/Smoke.emitting = true
|
||||
|
||||
func _physics_process(delta):
|
||||
#constant_linear_velocity = Vector3(1, 0, 0)
|
||||
translate_object_local(Vector3.FORWARD * speed * delta)
|
||||
if $Body.test_move($Body.global_transform, Vector3.FORWARD * speed):
|
||||
var hit_normal = global_transform.origin - source_position # is this correct?
|
||||
give_damage(null, global_transform.origin,hit_normal, damage, source_position, Globals.DamageType.EXPLOSION, 100)
|
||||
terminate()
|
||||
else:
|
||||
translate_object_local(Vector3.FORWARD * speed * delta)
|
||||
|
||||
# move_and_collide(global_transform.basis.x * Vector3.FORWARD * speed)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
|
@ -71,38 +74,45 @@ func _process(delta):
|
|||
halo.get_surface_override_material(0)["albedo_color"] = halo_color * fade
|
||||
|
||||
func give_damage(target: Node, hit_position: Vector3, hit_normal: Vector3, damage: int, source_position: Vector3, type: Globals.DamageType, push: float):
|
||||
if target.has_method(&'take_damage'): # we've hit a player or something else - the ywill handle everything like effects etc.
|
||||
target.rpc(&'take_damage',get_multiplayer_authority(), hit_position, hit_normal, damage, source_position, type, push)
|
||||
if target:
|
||||
if target.has_method(&'take_damage'): # we've hit a player or something else - they will handle everything like effects etc.
|
||||
target.rpc(&'take_damage',get_multiplayer_authority(), hit_position, hit_normal, damage, source_position, type, push)
|
||||
|
||||
# TODO take data from the material of the target and spawn an appropriate hit effect
|
||||
var hit_effect : Node = hit_effect_scene.instantiate()
|
||||
get_tree().root.add_child(hit_effect)
|
||||
hit_effect.global_transform.origin = hit_position
|
||||
hit_effect.global_transform.origin = global_transform.origin
|
||||
#print(impact_vfx.global_transform)
|
||||
var result = hit_effect.look_at(hit_position + hit_normal)
|
||||
var result = hit_effect.look_at(source_position)
|
||||
|
||||
if not result: # if the look_at failed (as it will on floors and ceilings) try another approach:
|
||||
hit_effect.look_at(hit_position + hit_normal, Vector3.LEFT)
|
||||
hit_effect.look_at(source_position, Vector3.LEFT)
|
||||
|
||||
hit_effect.rotate(hit_normal, randf_range(0, PI * 2))
|
||||
|
||||
rpc(&'terminate') # doesn't work!
|
||||
|
||||
#print(impact_vfx.global_transform)
|
||||
|
||||
func _on_Area3D_body_entered(body):
|
||||
if is_multiplayer_authority(): # only do this on the attacker's local instance of the game
|
||||
var hit_normal = body.global_transform.origin - global_transform.origin # is this correct?
|
||||
give_damage(body, global_transform.origin, hit_normal,damage, source_position, Globals.DamageType.EXPLOSION, 100)
|
||||
|
||||
set_process(false)
|
||||
@rpc(any_peer, call_local, reliable) func terminate() -> void: # cleanly end the rocket's life
|
||||
set_physics_process(false)
|
||||
|
||||
halo.hide()
|
||||
$OmniLight3D.light_energy = 0
|
||||
$OmniLight3D/Smoke.emitting = false
|
||||
$Area3D.queue_free()
|
||||
$Rocket.queue_free()
|
||||
$Area3D.set_deferred("monitoring",false)
|
||||
$Rocket.hide()
|
||||
$AmbientSound.stop()
|
||||
$Timer2.start()
|
||||
|
||||
func _on_Area3D_body_entered(body):
|
||||
if is_multiplayer_authority(): # only do this on the attacker's local instance of the game
|
||||
var hit_normal = body.global_transform.origin - global_transform.origin # is this correct?
|
||||
# direct hit
|
||||
give_damage(body, global_transform.origin, hit_normal,damage , source_position, Globals.DamageType.EXPLOSION, 100)
|
||||
|
||||
terminate()
|
||||
|
||||
func _on_Timer_timeout():
|
||||
queue_free()
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
[ext_resource type="AudioStream" uid="uid://bmjh522fpxeee" path="res://Assets/SFX/Player_Jetpack.wav" id="5_v5pxv"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_qjk68"]
|
||||
radius = 0.0853144
|
||||
height = 0.547775
|
||||
radius = 0.131113
|
||||
height = 0.70963
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_r8j3o"]
|
||||
interpolation_mode = 2
|
||||
|
@ -121,7 +121,7 @@ collision_mask = 11
|
|||
monitorable = false
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3D"]
|
||||
transform = Transform3D(0, 8.16337e-08, -1.86756, 1.86756, 0, 0, 0, -1.86756, -8.16337e-08, 0.000959158, 2.38419e-07, -0.307333)
|
||||
transform = Transform3D(0, 9.12042e-08, -2.08651, 2.08651, 0, 0, 0, -2.08651, -9.12042e-08, 0.000959158, 2.38419e-07, -0.307333)
|
||||
shape = SubResource( "CapsuleShape3D_qjk68" )
|
||||
|
||||
[node name="OmniLight3D" type="SpotLight3D" parent="."]
|
||||
|
@ -170,6 +170,15 @@ pitch_scale = 1.95
|
|||
autoplay = true
|
||||
doppler_tracking = 2
|
||||
|
||||
[node name="Body" type="AnimatableBody3D" parent="."]
|
||||
disable_mode = 2
|
||||
collision_layer = 0
|
||||
collision_mask = 3
|
||||
|
||||
[node name="CollisionShape3D2" type="CollisionShape3D" parent="Body"]
|
||||
transform = Transform3D(0, 8.16337e-08, -1.86756, 1.86756, 0, 0, 0, -1.86756, -8.16337e-08, 0.000959158, 2.38419e-07, -0.0284382)
|
||||
shape = SubResource( "CapsuleShape3D_qjk68" )
|
||||
|
||||
[connection signal="body_entered" from="Area3D" to="." method="_on_Area3D_body_entered"]
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||
[connection signal="timeout" from="Timer2" to="." method="_on_Timer2_timeout"]
|
||||
|
|
Loading…
Reference in New Issue