|
|
|
|
Reply From: |
abdolilah |
if the script is in xj then do:
var xj_pos= self.rect_position
if that did not work then do:
var xj_pos=self.position
if the script is in the parent of xj then do:
var xj_pos= $xj.rect_position
or:
var xj_pos= $xj.position
Thanks for the reply =). The script is intended to be in xi, where the positions of xi and every xj need to be accessed.
Neither of the suggestions work for me. The following being attached to a RigidBody node
extends RigidBody
func update_force():
var xi_pos_1 = self.position # <-----
var xi_pos_2 = self.rect_position # <-----
func _physics_process(delta):
update_force()
gives me the errors:
Invalid get index 'position' (on base: 'RigidBody (SpaceCell.gd)').
Invalid get index 'rect_position' (on base: 'RigidBody (SpaceCell.gd)').
toblin | 2020-03-06 15:22
witch godot version do you use
abdolilah | 2020-03-06 15:38
ah i get it
you are working in 3D
then do :
var ix_pos = self.translation
and you have to notice some thing hire :
if you do
print("ix_pos is: ", ix_pos)
then the output in the Debugger is going to be
ix_pos is: (0, 0, 0)
ok the value depend on the position of ix
if you want to access the x or y or z position you have to do
var ix_x_pos = self.translation.x
or
var ix_y_pos = self.translation.y
or
var ix_z_pos = self.translation.z
and have a nice day
abdolilah | 2020-03-06 15:55