feat: implement player movement controller and initial weapon framework including double barrel shotgun and explosive projectiles
This commit is contained in:
@@ -146,12 +146,11 @@ func _apply_impulse() -> void:
|
||||
var push_dir = camera.global_transform.basis.z.normalized()
|
||||
|
||||
# Apply impulse to player velocity
|
||||
player.velocity += push_dir * impulse_strength
|
||||
|
||||
# Small hack to ensure we aren't considered on floor if we shoot down
|
||||
if push_dir.y > 0:
|
||||
# Just slightly lift the player to break floor contact immediately
|
||||
player.position.y += 0.05
|
||||
var final_force = push_dir * impulse_strength
|
||||
if multiplayer.has_multiplayer_peer() and multiplayer.multiplayer_peer is not OfflineMultiplayerPeer:
|
||||
player.server_apply_impulse.rpc_id(1, final_force)
|
||||
else:
|
||||
player.apply_impulse(final_force)
|
||||
|
||||
func _play_muzzle_flash() -> void:
|
||||
if muzzle_flash:
|
||||
|
||||
@@ -191,16 +191,19 @@ func _explode(pos: Vector3) -> void:
|
||||
# Add a tiny bit of upward bias to knockback so it lifts them
|
||||
dir = (dir + Vector3(0, 0.5, 0)).normalized()
|
||||
|
||||
# Apply knockback if it has apply_impulse
|
||||
if col.has_method("apply_impulse"):
|
||||
col.apply_impulse(dir * final_knockback)
|
||||
# Apply knockback if it has server_apply_impulse (for rocket jumping)
|
||||
if col.has_method("server_apply_impulse") and col == owner_player:
|
||||
if multiplayer.has_multiplayer_peer() and multiplayer.multiplayer_peer is not OfflineMultiplayerPeer:
|
||||
col.server_apply_impulse.rpc_id(1, dir * final_knockback)
|
||||
else:
|
||||
col.apply_impulse(dir * final_knockback)
|
||||
|
||||
# Apply damage
|
||||
# Apply damage (and knockback for other players via take_damage)
|
||||
if col.has_method("take_damage"):
|
||||
if col == owner_player and not can_self_damage:
|
||||
# Skip self damage, but we still applied the knockback!
|
||||
# Skip self damage (we already applied knockback above)
|
||||
pass
|
||||
elif owner_player and owner_player.multiplayer.is_server():
|
||||
elif owner_player:
|
||||
col.take_damage(final_damage, target_pos, owner_player, dir * final_knockback)
|
||||
|
||||
# Broadcast Visual Explosion Effect to other peers
|
||||
|
||||
Reference in New Issue
Block a user