#Global_Position (On base: nil)
39 messages · Page 1 of 1 (latest)
It to me seems like it’s the target node that is causing the issue
Are you sure target is a valid node?
Did you print the target?
mmm. good idead.
I Anchor2d:<Area2D#25702696163>, will follow <null>
Yeah, looks like something aint right
Target point is my target
Which is just a node 2d with a colored rectangle for testing visual
Maybe I should manually (as in hard code temporrallrly) get it
I did it manually, it's still null.
The weird thing is, it worked before I make the Anchor2d a scene
but I might of changed more than just that. But regardless, this code is in Target Trigger not in the anchor
Do you set the target variable anywhere, because in the screen shot I only see point target and cam anchor
extends Area2D
@export var target: Node2D
@export var player: CharacterBody2D
@export var speed = int()
@export var Freeze_Cam = false
@export var lock_X = false
@export var lock_Y = false
var window_size = get_viewport_rect().size
@onready var cam = $Camera
const Accel = 40
##Math shit
var distance_threashold = 60
var target_pos = Vector2()
@onready var distance = global_position.distance_to(target_pos)
# Called when the node enters the scene tree for the first time.
func _ready():
print("I ",self,", will follow ", target)
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
# Un commented for ease of viewing
func _physics_process(delta):
target_pos = target.position
var mod_speed = speed + distance * delta * Accel
var camera_speed
if distance > distance_threashold:
camera_speed = 20 + mod_speed * Maths.cubic(distance, 0.5,-2,3,1)
print("Balls")
print(distance)
#vind pos
#dist
#MOVE MOVE MOVE
if !Freeze_Cam:
position = position.move_toward(target_pos, mod_speed * delta)
pass
You never set target to an actual node
Only say that it should be a Node2D
But don’t give it a node
? Is the point target the same variable as target?
OH MY GOSH
I just realized
I never set it in the achor after making it a sence
Boy, do I got egg on my face.
Yeah, again, stoned, lol
Thanks for your time though
Lol
Would you like a thanks in my credits?