started playing with rigidbody, not colliding yet
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
extends Node3D
|
||||
extends RigidBody3D
|
||||
|
||||
var bullet_speed
|
||||
var bullet_drop
|
||||
@@ -32,46 +32,46 @@ func _ready():
|
||||
av_x = deg_to_rad(rng.randf_range(-random_spread_amt,random_spread_amt))
|
||||
av_y = deg_to_rad(rng.randf_range(-random_spread_amt,random_spread_amt))
|
||||
av_z = deg_to_rad(rng.randf_range(-random_spread_amt,random_spread_amt))
|
||||
rotation += Vector3(av_x,av_y,av_z)
|
||||
#angular_velocity += Vector3(av_x,av_y,av_z)
|
||||
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed)
|
||||
timer.start()
|
||||
visible = false
|
||||
ray.target_position.z *= (bullet_speed/150)
|
||||
|
||||
func MoveAndCollide():
|
||||
pass
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
position += transform.basis * Vector3(0, 0, -bullet_speed) * delta
|
||||
print(player_velocity)
|
||||
rotation.x = clamp(rotation.x - delta * bullet_drop,deg_to_rad(-90),deg_to_rad(90))
|
||||
|
||||
distance_from_player = abs(self.global_position - player_position)
|
||||
|
||||
if distance_from_player.x > 2 or distance_from_player.y > 2 or distance_from_player.z > 2:
|
||||
visible = true
|
||||
|
||||
|
||||
|
||||
func _on_body_entered(body):
|
||||
|
||||
if ray.is_colliding() and !ray.get_collider().is_in_group("player"):
|
||||
|
||||
if !body.is_in_group("player"):
|
||||
mesh.visible = false
|
||||
ray.enabled = false
|
||||
|
||||
#bullethole effect
|
||||
ray.get_collider().add_child(instance_bullethole)
|
||||
instance_bullethole.global_transform.origin = ray.get_collision_point()
|
||||
instance_bullethole.look_at(ray.get_collision_point() + ray.get_collision_normal(), Vector3.UP)
|
||||
|
||||
#move rigidbodies
|
||||
if ray.get_collider().is_in_group("scene_rigidbody"):
|
||||
ray.get_collider().linear_velocity += transform.basis * Vector3(0,0,-1 * bullet_force_mod)
|
||||
|
||||
if ray.get_collider().is_in_group("breakable"):
|
||||
var current_velocity = transform.basis * Vector3(0,0,-1 * bullet_force_mod)
|
||||
ray.get_collider().breaking(current_velocity)
|
||||
|
||||
#bullethole effect
|
||||
body.add_child(instance_bullethole)
|
||||
instance_bullethole.global_transform.origin = body.get_collision_point()
|
||||
instance_bullethole.look_at(body.get_collision_point() + body.get_collision_normal(), Vector3.UP)
|
||||
|
||||
##move rigidbodies
|
||||
#if ray.get_collider().is_in_group("scene_rigidbody"):
|
||||
#ray.get_collider().linear_velocity += transform.basis * Vector3(0,0,-1 * bullet_force_mod)
|
||||
|
||||
if body.is_in_group("breakable"):
|
||||
var current_velocity = transform.basis * Vector3(0,0,-1 * bullet_force_mod)
|
||||
body.breaking(current_velocity)
|
||||
|
||||
|
||||
if ray.get_collider().is_in_group("enemy"):
|
||||
hit_indicator.play()
|
||||
enemy_particles.emitting = true
|
||||
ray.get_collider().hit(bullet_damage)
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
queue_free()
|
||||
|
||||
if body.is_in_group("enemy"):
|
||||
hit_indicator.play()
|
||||
enemy_particles.emitting = true
|
||||
body.hit(bullet_damage)
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
queue_free()
|
||||
|
||||
@@ -224,57 +224,58 @@ func _headbob(time) -> Vector3:
|
||||
|
||||
|
||||
func _on_pick_up_detection_body_entered(body):
|
||||
|
||||
if body.pickupType == "stamina":
|
||||
pickupmsg = pickup_announce.instantiate()
|
||||
pickupmsg.pickuptext = "stamina"
|
||||
get_parent().add_child(pickupmsg)
|
||||
remaining_stamina += (body.rand_amt/100) * MAX_STAMINA
|
||||
pickup_sound.pitch_scale = 1 + rng.randf_range(-.3,.3)
|
||||
pickup_sound.play()
|
||||
body.queue_free()
|
||||
elif body.pickupType == "ammo":
|
||||
pickupmsg = pickup_announce.instantiate()
|
||||
pickupmsg.pickuptext = "ammo"
|
||||
get_parent().add_child(pickupmsg)
|
||||
level_control.ammo_reserve[level_control.current_gun_index] += int((body.rand_amt/100) * gun.max_ammo)
|
||||
picked_up = true
|
||||
picked_up_text = "ammo"
|
||||
pickup_sound.pitch_scale = 1 + rng.randf_range(-.3,.3)
|
||||
pickup_sound.play()
|
||||
body.queue_free()
|
||||
elif body.pickupType == "money":
|
||||
pickupmsg = pickup_announce.instantiate()
|
||||
pickupmsg.pickuptext = "$" + str(int(body.rand_amt))
|
||||
get_parent().add_child(pickupmsg)
|
||||
level_control.money += int(body.rand_amt)
|
||||
picked_up = true
|
||||
picked_up_text = "ammo"
|
||||
pickup_sound.pitch_scale = 1 + rng.randf_range(-.3,.3)
|
||||
pickup_sound.play()
|
||||
body.queue_free()
|
||||
elif body.pickupType == "jump":
|
||||
pickupmsg = pickup_announce.instantiate()
|
||||
pickupmsg.pickuptext = "jump"
|
||||
get_parent().add_child(pickupmsg)
|
||||
double_jump = true
|
||||
picked_up = true
|
||||
picked_up_text = "double jump"
|
||||
pickup_sound.pitch_scale = 1 + rng.randf_range(-.3,.3)
|
||||
pickup_sound.play()
|
||||
body.queue_free()
|
||||
elif body.pickupType == "weapon":
|
||||
pickup_sound.pitch_scale = 1 + rng.randf_range(-.3,.3)
|
||||
pickup_sound.play()
|
||||
level_control.held_guns.append(body.gun_resource)
|
||||
var instance_gun = body.gun_resource.instantiate()
|
||||
level_control.ammo_current.append(instance_gun.max_ammo)
|
||||
level_control.ammo_reserve.append(instance_gun.max_ammo * instance_gun.start_mags)
|
||||
body.queue_free()
|
||||
var weapon_id = level_control.held_guns.size() - 1
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(weapon_id)
|
||||
|
||||
|
||||
if body.is_in_group("pickup"):
|
||||
if body.pickupType == "stamina":
|
||||
pickupmsg = pickup_announce.instantiate()
|
||||
pickupmsg.pickuptext = "stamina"
|
||||
get_parent().add_child(pickupmsg)
|
||||
remaining_stamina += (body.rand_amt/100) * MAX_STAMINA
|
||||
pickup_sound.pitch_scale = 1 + rng.randf_range(-.3,.3)
|
||||
pickup_sound.play()
|
||||
body.queue_free()
|
||||
elif body.pickupType == "ammo":
|
||||
pickupmsg = pickup_announce.instantiate()
|
||||
pickupmsg.pickuptext = "ammo"
|
||||
get_parent().add_child(pickupmsg)
|
||||
level_control.ammo_reserve[level_control.current_gun_index] += int((body.rand_amt/100) * gun.max_ammo)
|
||||
picked_up = true
|
||||
picked_up_text = "ammo"
|
||||
pickup_sound.pitch_scale = 1 + rng.randf_range(-.3,.3)
|
||||
pickup_sound.play()
|
||||
body.queue_free()
|
||||
elif body.pickupType == "money":
|
||||
pickupmsg = pickup_announce.instantiate()
|
||||
pickupmsg.pickuptext = "$" + str(int(body.rand_amt))
|
||||
get_parent().add_child(pickupmsg)
|
||||
level_control.money += int(body.rand_amt)
|
||||
picked_up = true
|
||||
picked_up_text = "ammo"
|
||||
pickup_sound.pitch_scale = 1 + rng.randf_range(-.3,.3)
|
||||
pickup_sound.play()
|
||||
body.queue_free()
|
||||
elif body.pickupType == "jump":
|
||||
pickupmsg = pickup_announce.instantiate()
|
||||
pickupmsg.pickuptext = "jump"
|
||||
get_parent().add_child(pickupmsg)
|
||||
double_jump = true
|
||||
picked_up = true
|
||||
picked_up_text = "double jump"
|
||||
pickup_sound.pitch_scale = 1 + rng.randf_range(-.3,.3)
|
||||
pickup_sound.play()
|
||||
body.queue_free()
|
||||
elif body.pickupType == "weapon":
|
||||
pickup_sound.pitch_scale = 1 + rng.randf_range(-.3,.3)
|
||||
pickup_sound.play()
|
||||
level_control.held_guns.append(body.gun_resource)
|
||||
var instance_gun = body.gun_resource.instantiate()
|
||||
level_control.ammo_current.append(instance_gun.max_ammo)
|
||||
level_control.ammo_reserve.append(instance_gun.max_ammo * instance_gun.start_mags)
|
||||
body.queue_free()
|
||||
var weapon_id = level_control.held_guns.size() - 1
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(weapon_id)
|
||||
|
||||
|
||||
func _on_pick_up_magnet_body_entered(body):
|
||||
if body.is_in_group("pickup") and body.is_in_group("magnet"):
|
||||
|
||||
Reference in New Issue
Block a user