Better bullet traces and raycast for hitscan
This commit is contained in:
@ -2,8 +2,9 @@ extends Node3D
|
||||
|
||||
const SPEED = 715
|
||||
|
||||
@onready var mesh = $MeshInstance3D
|
||||
@onready var ray = $RayCast3D
|
||||
@onready var mesh = $RigidBody3D/MeshInstance3D
|
||||
@onready var rigid_body_3d: RigidBody3D = $RigidBody3D
|
||||
@onready var ray = $RigidBody3D/RayCast3D
|
||||
@onready var particles = $GPUParticles3D
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
@ -14,11 +15,15 @@ func _ready() -> void:
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
position += transform.basis * Vector3(0, 0, SPEED) * delta
|
||||
ray.collision_mask = 1
|
||||
ray.enabled = 1
|
||||
rigid_body_3d.set_use_continuous_collision_detection(true)
|
||||
#ray.collision_mask = 1
|
||||
#ray.enabled = 1
|
||||
ray.target_position.z = SPEED / Engine.get_frames_per_second()
|
||||
if ray.is_colliding():
|
||||
mesh.visible = false
|
||||
rigid_body_3d.visible = false
|
||||
particles.emitting = true
|
||||
#if ray.get_collider().is_in_group("body"):
|
||||
#print("head")
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
queue_free()
|
||||
|
||||
|
Reference in New Issue
Block a user