Bullet gravity
This commit is contained in:
parent
f224c93c93
commit
414d22f483
1 changed files with 3 additions and 3 deletions
|
@ -3,7 +3,7 @@ extends Area3D
|
||||||
signal exploded
|
signal exploded
|
||||||
|
|
||||||
@export var muzzle_velocity = 100 # How fast the bullets are
|
@export var muzzle_velocity = 100 # How fast the bullets are
|
||||||
@export var g = Vector3.DOWN * 20
|
@export var g = Vector3.DOWN * 5
|
||||||
|
|
||||||
var velocity = Vector3.ZERO
|
var velocity = Vector3.ZERO
|
||||||
|
|
||||||
|
@ -12,11 +12,11 @@ var godmode = 0
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
# velocity += g * delta # Uncomment this for bullet gravity
|
velocity += g * delta # Bullet gravity
|
||||||
look_at(transform.origin + velocity.normalized(), Vector3.UP)
|
look_at(transform.origin + velocity.normalized(), Vector3.UP)
|
||||||
transform.origin += velocity * delta
|
transform.origin += velocity * delta
|
||||||
|
|
||||||
for body in get_overlapping_bodies(): ### THIS IS OLD LOGIC, REPLACE. I'D RECOMMEND TO CHECK BY GROUP AND NOT BY NODE
|
for body in get_overlapping_bodies():
|
||||||
if body.is_in_group("human"):
|
if body.is_in_group("human"):
|
||||||
print("Bullet hit a human player")
|
print("Bullet hit a human player")
|
||||||
Global.playerHealth = Global.playerHealth - 10
|
Global.playerHealth = Global.playerHealth - 10
|
||||||
|
|
Loading…
Reference in a new issue