The good ole relative to global position question, Please help cant figure it out for weeks

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Chevon

First Ill share the entire code

Moving_Platform.gd

extends KinematicBody2D

var points
export var target_positions=
var currentpoint
var currentpointindex
var reach_target
var SPEED = 100
var vectornormal
---------NEEDS WORK BROKEN
func _ready():
var pos1 = get_node(“target1”)
target_positions.insert(0,get_position())
target_positions.insert(1,pos1.global_position)
reach_target = false
currentpointindex = 0
currentpoint = target_positions[currentpointindex]
print(target_positions[1])

func _process(delta):
-------check target index to increase
reach_target = false
if Global_Vars.has_reached_target(get_position(), currentpoint) and not reach_target:
currentpointindex += 1
reach_target = true
if currentpointindex >= target_positions.size()-1:
currentpointindex = 0
currentpoint = target_positions[currentpointindex]
-------MOVEMENT TO TARGET
vectornormal = (currentpoint - get_position()).normalized()
print(vectornormal)
position += (vectornormal * SPEED * delta)
CODE_END

Node layout:
Kinematic Body
------Collision Shape
---------------Sprite
------Position2D


The issue I’m having is that when the platform is moving towards the position2D’s location it treats its bottom left position as its center. I had 2 target positions and decided its a bit redundant so I used the platforms initial position as the first(second) target. The position I grabbed from the platform works fine. Im not sure what Im missing.

Keep in mind that the Moving_Platforms scene has everything centered and positioned at Vector.Zero(0,0)

Okay so because the target location is directly below at an x difference of 0 I printed out both the initial position (the first target) and the second target and there global X values are somehow different, Which partially solves my problem. Now the question is why is the global x value different?..

Chevon | 2019-07-30 10:28