Added crosshair

This commit is contained in:
Paul Black 2023-02-21 12:53:13 -07:00
parent e11945f93f
commit ec05c7d61a
14 changed files with 58 additions and 13 deletions

BIN
.DS_Store vendored

Binary file not shown.

View file

@ -11,14 +11,13 @@ var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
@onready var neck := $CollisionShape3D/Neck
@onready var camera := $CollisionShape3D/Neck/Camera3D
@onready var selfTeddy = self.get_path()
var teddyNode
@onready var teddyParent = get_node(selfTeddy).get_parent()
var globalscene
func _ready():
Global.playingGame = true
Global.selfTeddy = selfTeddy
teddyNode = get_node(selfTeddy)
func _unhandled_input(event):
if event is InputEventMouseButton:
@ -93,7 +92,7 @@ func _physics_process(delta):
if Global.menuOpen == false:
print("shoot")
var b = Bullet.instantiate()
teddyNode.add_child(b) ### DO RESEARCH ON WHAT OWNER IS DEFINED AS, I FORGOT WHAT IT IS. FOR NOW IT WILL BE REPLACED WITH teddyNode BUT BULLETS ARE WACK THIS WAY
teddyParent.add_child(b)
b.transform = $CollisionShape3D/Neck/Camera3D/BulletGenerator.global_transform
b.velocity = -b.global_transform.basis.z * b.muzzle_velocity
if Input.is_action_just_pressed("console"):

View file

@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.cte
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false

View file

@ -17,7 +17,7 @@ func _physics_process(delta):
transform.origin += velocity * delta
for body in get_overlapping_bodies():
if body.get_path() == Global.selfTeddy:
if body.get_path() == Global.selfTeddy: # We need to modify this to make the player not invinsible
pass
elif body.is_in_group("human"):
print("Bullet hit a human player")
@ -30,6 +30,8 @@ func _physics_process(delta):
else:
print("Bullet hit something else")
self.queue_free()
await get_tree().create_timer(2).timeout
self.queue_free()
func _on_Shell_body_entered(body):

View file

@ -4,15 +4,15 @@
[ext_resource type="PackedScene" uid="uid://pni78bumc5f5" path="res://objects/Bullet/model/Bullet.dae" id="2"]
[sub_resource type="BoxShape3D" id="BoxShape3D_jya8v"]
size = Vector3(0.40456, 0.406836, 0.393048)
size = Vector3(0.173025, 0.105384, 0.0953652)
[node name="Bullet" type="Area3D" groups=["bullet"]]
transform = Transform3D(0.979715, 0, 0, 0, 0.979715, 0, 0, 0, 0.979715, 0, 0, 0)
script = ExtResource("1")
[node name="CollisionShape3D" type="CollisionShape3D" parent="." groups=["bullet"]]
transform = Transform3D(0.957696, 0, 0, 0, 1, 0, 0, 0, 1.66763, 0, 0, -0.295843)
transform = Transform3D(0.957696, 0, 0, 0, 1, 0, 0, 0, 1.66763, 2.08165e-12, 0.109855, 2.08165e-12)
shape = SubResource("BoxShape3D_jya8v")
[node name="Bullet" parent="." instance=ExtResource("2")]
transform = Transform3D(0.200224, 0, 0, 0, -8.75207e-09, 0.200224, 0, -0.200224, -8.75207e-09, 0, 0, 0)
transform = Transform3D(0.05, -6.0734e-17, -2.65477e-24, 0, -2.18557e-09, 0.0499999, -6.0734e-17, -0.05, -2.18557e-09, 2.08165e-12, 0.0990669, 0.0735058)

View file

@ -26,6 +26,7 @@ skins/use_named_skins=true
animation/import=true
animation/fps=15
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
meshes/handle_gltf_embedded_images=1
gltf/embedded_image_handling=1

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://ytbacsuahxie"]
[gd_scene load_steps=3 format=3 uid="uid://ytbacsuahxie"]
[ext_resource type="Script" path="res://scripts/HUD.gd" id="1_mqiiw"]
[ext_resource type="Texture2D" uid="uid://tjvdle3jlb6g" path="res://textures/crosshair1.png" id="2_5dvrx"]
[node name="HUD" type="Control"]
layout_mode = 3
@ -29,3 +30,8 @@ offset_top = 602.0
offset_right = 165.0
offset_bottom = 629.0
value = 100.0
[node name="Crosshair1" type="Sprite2D" parent="."]
position = Vector2(575, 323)
scale = Vector2(0.0351562, 0.0351562)
texture = ExtResource("2_5dvrx")

View file

@ -52,3 +52,4 @@ func reset_variables():
func add_player_character(mapNode):
var player_character = preload("res://scenes/Teddy.tscn").instantiate()
mapNode.add_child(player_character)
player_character.position.y = 1

View file

@ -37,6 +37,7 @@ func _on_start_button_pressed():
print("Player chose player limit: ", intMAX)
Networking.create_server(intPORT, intMAX)
Networking.load_map(SCENE)
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
else:
$mapSelected.text = "NO MAX PLAYERS SELECTED"
else:

View file

@ -3,6 +3,7 @@ extends Node
var peer = ENetMultiplayerPeer.new()
var SCENE = "res://scenes/playground.tscn"
func create_server(port, maxPlayers):
var result = peer.create_server(port, maxPlayers) # Second paramater specifies the player limit. Can be anything between 1 and 4095
multiplayer.multiplayer_peer = peer
@ -27,7 +28,7 @@ func load_map(map):
Global.multiplayerCurrent = true
get_tree().change_scene_to_file(map)
@rpc
@rpc("any_peer", "call_remote")
func add_newly_connected_player_character():
print("add_newly_connected_player_character() has been run!")
load_map(SCENE)

View file

@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/blender.svg-30745d3fde109c2dd09fe06f35ced49b.
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false

View file

@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/godot.svg-dfd0c6d0b550de1675c2ab4f6216d77f.ct
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false

BIN
textures/crosshair1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://tjvdle3jlb6g"
path="res://.godot/imported/crosshair1.png-11432286ab233e4857bd47dda54ae015.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/crosshair1.png"
dest_files=["res://.godot/imported/crosshair1.png-11432286ab233e4857bd47dda54ae015.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1