Godot Version
Godot Version 4.6.2
Question
Ok, Hear Me Out Ya’ll, This Bug Is Going Above My Head
So, I Made These Towers That Will Shoot Projectiles At Me At Random Intervals
When I First Start The Game, Everything Is Working Fine But After Going Through 15 Rooms to The Next Safe Room (The Rooms Are Randomly And Procedurally Generated Using Pre-Made Room Scenes), The Position Of The Projectiles Is Not Where It Should Be But Rather, It’s Instantiated Position Is Somewhere Else (Right Below The World Origin I Think, Not Sure About The Specific Position Tho)
The Projectiles Are Supposed To Instantiate At The Red Crystal And Travel Towards My Direction But The Position Is Completely Wrong
I Tried Everything But Nothing Works
I’d Appreciate If Someone Helped Me
Here’s The Video Y’all
Sorry For Bad Quality, My laptop Ain’t The Best
THIS IS THE ENEMY TOWER SCRIPT (THE ONE WHO SHOOTS THE PROJECTILE)
extends Node3D
@onready var crystal = $Soul_Crystal/Crystal
@onready var shoot_timer = $ShootTimer
@onready var bullet_pos = $BulletPos
var can_shoot: = true
var in_range = false
@onready var player_check = $PlayerCheck
@onready var Player = get_tree().get_first_node_in_group("player")
# Called when the node enters the scene tree for the first time.
func _ready():
shoot_timer.timeout.connect(on_shoot_timer_timeout)
func _physics_process(delta):
bullet_pos.look_at(Player.global_position)
crystal.rotation.y += 15 * delta
if can_shoot and in_range:
orb_shoot()
can_shoot = false
shoot_timer.start()
func _on_player_check_body_entered(body):
if body.is_in_group("player"):
in_range = true
func _on_player_check_body_exited(body):
if body.is_in_group("player"):
in_range = false
func on_shoot_timer_timeout():
can_shoot = true
func orb_shoot():
var SOUL_ORB = load("res://Enemies/Soul_torch/soul_orb.tscn")
var orb = SOUL_ORB.instantiate()
var spawn_pos: Vector3 = bullet_pos.global_position
orb.position = spawn_pos
orb.transform.basis = bullet_pos.global_transform.basis
get_parent().add_child(orb)
THIS IS THE PROJECTILE SCRIPT
extends CharacterBody3D
@onready var soul_orb = $"."
@onready var Player = get_tree().get_first_node_in_group("player")
const SPEED = 80.0
const JUMP_VELOCITY = 4.5
var dist = 0.0
var max_dist = 1500.0
func _physics_process(delta):
position += transform.basis * Vector3(0,0,-SPEED) * delta
dist += 10
if dist >= max_dist:
soul_orb.queue_free()
move_and_slide()