rocket launcher moves objects, blast radius not falling off properly yet
This commit is contained in:
@@ -33,8 +33,10 @@ var start_sensitivity
|
||||
@export var BASE_FOV : float = 80
|
||||
@export var FOV_CHANGE = 1.5
|
||||
|
||||
@export_group("Gun")
|
||||
@export var gun : Node
|
||||
#@export_group("Gun") DELETE IF DOESNT CAUSE ISSUES
|
||||
#@export
|
||||
|
||||
var gun : Node
|
||||
|
||||
@onready var gun_ray = $Head/Camera3D/GunRay
|
||||
@onready var level_control = $".."
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
extends RigidBody3D
|
||||
|
||||
@export var explosion : Resource
|
||||
@export var blast_radius : Node
|
||||
@export var blast_radius_falloff : Resource
|
||||
@onready var radius_shape = $BlastRadius/radiusShape
|
||||
|
||||
var blast_power
|
||||
var bullet_speed
|
||||
var player_velocity
|
||||
var bullet_damage
|
||||
@@ -18,8 +22,30 @@ func _process(delta):
|
||||
|
||||
|
||||
func _on_body_shape_entered(body_rid, body, body_shape_index, local_shape_index):
|
||||
#move objects
|
||||
explode()
|
||||
|
||||
#Spawn gpu particles
|
||||
var explosionspawn = explosion.instantiate()
|
||||
explosionspawn.position = self.global_position
|
||||
explosionspawn.transform.basis = self.global_transform.basis
|
||||
get_tree().get_root().add_child(explosionspawn)
|
||||
queue_free()
|
||||
|
||||
func explode():
|
||||
#get all collision objects that can be moved
|
||||
var moveable_rigidbodies = blast_radius.get_overlapping_bodies()
|
||||
#for each object determine vector from center of blast radius
|
||||
#apply linear velocity power as the inverse % of distance towards the edge (bonus points if using curve texture)
|
||||
#break breakable objects
|
||||
for body in moveable_rigidbodies:
|
||||
if body.is_in_group("scene_rigidbody"):
|
||||
var blast_direction = (body.global_position - blast_radius.global_position).normalized()
|
||||
var blast_amount = (10 / (body.global_position - blast_radius.global_position).length()) / 10
|
||||
print("blast direction "+str(blast_direction))
|
||||
print("blast amount "+str(blast_amount))
|
||||
var blast_velocity = blast_direction * blast_power * blast_amount
|
||||
if body.is_in_group("breakable"):
|
||||
body.breaking(blast_velocity)
|
||||
else:
|
||||
body.linear_velocity += blast_velocity
|
||||
|
||||
@@ -14,7 +14,7 @@ var cycle_count
|
||||
@export var max_ammo = 15
|
||||
@export var start_mags = 3
|
||||
@export var bullet_damage = 1
|
||||
@export var bullet_force_mod = 5.0
|
||||
@export var blast_power = 50.0
|
||||
@export var bullet_speed : float = 150
|
||||
@export var bullet_drop = .3
|
||||
@export var random_spread_amt = 1.0
|
||||
@@ -97,6 +97,7 @@ func shoot(delta):
|
||||
instance_bullet.bullet_speed = bullet_speed
|
||||
instance_bullet.player_velocity = player.velocity
|
||||
instance_bullet.bullet_damage = bullet_damage
|
||||
instance_bullet.blast_power = blast_power
|
||||
instance_bullet.player_position = player.global_position
|
||||
get_tree().get_root().add_child(instance_bullet)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user